Skip to content

Instantly share code, notes, and snippets.

//custom excerpt
function get_post_excerpt($post_id,$elips, $length, $cta, $class){
$the_post = get_post($post_id); //Gets post ID
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
$the_excerpt = $content = apply_filters('the_content', $the_excerpt); //keep formatting
$the_excerpt = str_replace('\]\]\>', ']]>', $the_excerpt); //keep formatting continued..
$excerpt_length = $length; //Sets excerpt length by word count
$the_excerpt = strip_tags($the_excerpt, '<p>'); //Strips tags and images (except for <p> tags)
$words = explode(' ', $the_excerpt, $excerpt_length + 1);
if(count($words) > $excerpt_length) :
@nixonmedia
nixonmedia / Restrict-Sub-Pages.php
Last active January 19, 2018 21:12
Restrict Wordpress pages a specific page ID and also apply the parent or grand parent template
function wpex_restrict_page_to_logged_in_user() {
// Get global post
global $post;
// Prevent access to page with ID of x and all children of this page
$page_id = 5631;
$parent = $post->post_parent;
$get_grandparent = get_post($parent);
$grandparent = $get_grandparent->post_parent;
<?php
/*Template Name: Taking Action */
get_header();
global $post;
$postID = $post->ID;
global $postID;
?>
<div class="wrap container">
<div class="content-area row" >
<div class="col-md-8" id="content">
<?php
/*
Template Name: Orders
*/
get_header();
?>
<div class="container">
<h1 class="title"><?php the_title(); ?></h1>
<?php
add_filter("gform_address_types", "us_address", 10, 2);
function us_address($address_types, $form_id){
$address_types["us"] = array(
"label" => "United States",
"country" => "USAB",
"zip_label" => "Zip Code",
"state_label" => "State",
"states" => array(
"" => "",
<?php
function custom_posts_per_page( $query ) {
if ( $query->is_archive('success-story') ) {
set_query_var('posts_per_page', 9);
}
}
add_action( 'pre_get_posts', 'custom_posts_per_page' );
<script>
$ = jQuery;
$(document).ready(function(e) {
// when you click and element that has the attribute data-toggle="offcanvas"
// open the sidebar
$('[data-toggle="offcanvas"]').click(function () {
//add an active class to the button
<div id="IDX-main" class="IDX-notLoggedIn IDX-page-listing IDX-category-details IDX-type-default IDX-wrapper-standard IDX-widgetReferer " data-pageid="8406">
<div id="IDX-Subheader"><div id="IDX-Subheader-Global" class="IDX-Subheader-type"><p>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous" />
</p></div>
</div>
<div class="container">
<script src="//kingswayrealty.idxbroker.com/idx/customshowcasejs.php?widgetid=8396"></script><style type="text/css"> #IDX-showcaseGallery-8396 { } #IDX-showcaseGallery-8396 .IDX-showcaseCell {width: 33.333333%; min-width: 33.333333%; padding:3px !important; vertical-align:top; display: inline-block !important; margin-bottom: 5px;} #IDX-showcaseGallery-8396 .IDX-showcaseRow {display: inline-block !important; width:100%; margin-bottom:10px;} #IDX-showcaseGallery-8396 .IDX-showcaseContainer a {height: auto !important} #IDX-showcaseGallery-8396 .IDX-showcaseLink:before{height: auto; content: none !important} #IDX-showcaseGallery-8396 .IDX-showcaseLink {display: block;position: relative; padding-top: 66%;} #IDX-showcaseGallery-8396 .IDX-showcasePhoto {max-height: 100%;margin: auto; height: auto; position: abso
<style type="text/css">#IDX-quicksearch-8393 {text-align:right;}#IDX-quicksearchForm-8393 .IDX-qsLabel {margin: 0;padding-top: 3px;}#IDX-quicksearchForm-8393 .IDX-qsSelectInput {width: 180px;}#IDX-quicksearchForm-8393 .IDX-qsInput {margin: 0 2px;}#IDX-quicksearchForm-8393 > .IDX-qsFieldWrap {display: inline-block; text-align: left;}#IDX-quicksearchForm-8393 {display: inline-block;}#IDX-quicksearch-8393 { border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #ccc; box-shadow: 1px 1px 5px #777; -webkit-box-shadow: 1px 1px 5px #777; } #IDX-quicksearch-8393 label { margin: 0 5px;} #IDX-qsIdxIDWrap-8393 { margin-top: 10px; } #IDX-quicksearch-8393 select { width: 100% } .IDX-qsTextInput { width: 120px } .IDX-qsFieldWrap { padding: 5px 10px; text-align: right; } #IDX-qsMinPriceLabel-8393 { float: left; } #IDX-qsMaxPriceLabel-8393 { float: left; } #IDX-qsMinBedLabel-8393 { float:left; } #IDX-qsMinSqFtLabel-8393 { float: left; } #IDX-qsMinBathLabel-8393 { float: left; } #IDX-qsCityListLabel-8393 { float