WordPress.org

Ready to get started?Download WordPress

Forums

Add Images/Content To Bottom Category Posts (1 post)

  1. Murray644
    Member
    Posted 1 year ago #

    I am trying to add some content to specific category posts, images that will show up every time I write a post with that category. I got this to work using functions but I want it to be at the bottom of post right under my text and above my other widgets (share buttons etc) you can see example here. It is the text that says TEST TEST TEST.... I want that to be above my related posts widget.

    This is the code I used:

    add_filter('the_content', 'custom_category_text');
    
    function custom_category_text($content){
    global $post;
    $custom_category_text = '<p>TEST TEST TEST Put your Custom category text here.</p>';
    if(in_category('97')){ // change catetegory ID 3
    	$content =  $content . $custom_category_text;
    }
    return $content;
    }

    I have read it may be easier to uses single.php file to do this but I don't have a single.php file, I also don't have an index.php file. I am using the Ctystal child theme. Genesis has an index.php but not the child theme so I went ahead and did it using function.

    What code can I add to make it post above those other widgets?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic