Created
October 30, 2015 20:40
-
-
Save LinzardMac/5b18ace5b2427f72c307 to your computer and use it in GitHub Desktop.
is_single() and is_singular() not running the filter on the queried object
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
/* | |
* Test case #1 | |
*/ | |
add_filter( 'the_title', 'my_add_custom_content' ); | |
function my_add_custom_content( $title) { | |
if ( is_singular( 'events' ) ): | |
$postID = get_the_ID(); | |
$html = '<a href="#" class="goingLink setGoing" id="'.$postID.'" data-value="'. $postID .'">I\'m Going</a><div id="fb-root"></div>'; | |
$title .= $html; | |
endif; | |
return $title; | |
} | |
/* | |
* Test Case #2 | |
*/ | |
add_filter( 'the_title', 'my_add_custom_content' ); | |
function my_add_custom_content( $title): | |
$postID = get_the_ID(); | |
$postType = get_post_type( $postID ); | |
if($postType == 'events' && is_single()){ | |
$html = '<a href="#" class="goingLink setGoing" id="'.$postID.'" data-value="'. $postID .'">I\'m Going</a><div id="fb-root"></div>'; | |
$title .= $html; | |
endif; | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment