This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: CWD YouTube Channel | |
Version: 0.1 | |
Plugin URI: http://www.celticwebdesign.net | |
Description: Render YouTube video count | |
Author: Darren Stevens | |
Author URI: http://www.celticwebdesign.net | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://wordpress.stackexchange.com/questions/35724/function-to-return-true-if-current-page-has-child-pages | |
function wpb_list_child_pages() { | |
global $post; | |
// does page have children? | |
$children = get_pages( array( 'child_of' => $post->ID ) ); | |
if( count( $children ) == 0 ) { | |
// not a parent page, | |
// show children page links of parent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://wp-snppts.com/archive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( get_field('above_footer') ) { | |
$post_id = get_the_id(); | |
} else { | |
$post_id = 41; | |
} | |
$vcM = Vc_Manager::getInstance(); | |
$vc = $vcM->vc(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_all_categories($taxonomy) { | |
$terms = get_terms( | |
array( | |
'taxonomy' => $taxonomy, | |
'hide_empty' => false, | |
) | |
); | |
if ( $terms && ! is_wp_error( $terms ) ) : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.wpbeginner.com/wp-tutorials/how-to-limit-search-results-for-specific-post-types-in-wordpress/ | |
function searchfilter($query) { | |
if ($query->is_search && !is_admin() ) { | |
$query->set('post_type',array('recipes')); | |
$query->set('posts_per_page',10); | |
} | |
return $query; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/965235/how-can-i-truncate-a-string-to-the-first-20-words-in-php | |
function limit_text($text, $limit) { | |
if (str_word_count($text, 0) > $limit) { | |
$words = str_word_count($text, 2); | |
$pos = array_keys($words); | |
$text = substr($text, 0, $pos[$limit]) . '...'; | |
} | |
return $text; | |
} |