Skip to content

Instantly share code, notes, and snippets.

<?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">
@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;
//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('\]\]\>', ']]&gt;', $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) :