• hello! I’m trying to filter for the content in excerpts of posts wherever the excerpt would normally display, and I’ve had success so far by using this:

    add_filter( 'get_the_excerpt', 'excerpt_custom_content' );
    function excerpt_custom_content($content){
    	if( is_post_type_archive('teachings') ) {
    		$content .= '<p>custom content</p>';
        	}
        	return $content;
    }

    that get the custom content to display in the excerpts on the archive pages for my custom post type, but then i ran into a problem when I created a custom taxonomy (book) for my custom post type (teaching), and added a link to my menu to display the posts which selected ‘deuteronomy’ in the ‘book’ taxonomy (so the link looks like this “calvary2sun.com/book/deuteronomy).

    To the best of my understanding this is a category archive page, so I entered the code

    add_filter( 'get_the_excerpt', 'excerpt_custom_content_cat' );
    function excerpt_custom_content_cat($content){
    	if(is_category() ) {
    		$content .= '<p>custom content</p>';
        	}
        	return $content;
    }

    in my functions.php but nothing changed on the page.

    I’ll also need it to only apply to my custom post type ‘teachings’, so… I’m very much at a loss on this one, and would appreciate any bit of help.

    thank you very much for reading this posts and thank you in advance for any help you provide!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_the_excerpt if is_category not working’ is closed to new replies.