• I want to display custom text at the end of each post but above the related posts thumbnail.

    In my previous theme it was

    <?php
    function text_after_content($content) {
    if ( in_category('First') ) {
    $content.= "<p>Custom text 1</p>";
    }
    if ( in_category('Second') ) {
    $content.= "<p>Custom text 2</p>";
    }
    }
    return $content;
    }
    add_filter ('the_content', 'text_after_content');
    ?>

    But this no longer works on my new theme. This is the theme I’m using https://uxlthemes.com/demo/?demo=jorvik

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried adding debug messages at the start of that function? (outside of any conditional loops) to verify the new theme users the “the_content” filter?

    Thread Starter nzt1012

    (@nzt1012)

    Hi Rajesh, thank you for your reply.

    No I haven’t. How do I do that? I used Google to get the original code as well. I am not very good at this stuff.

    <?php
    function text_after_content($content) {
    
    echo "<xmp>content:" . __LINE__ . "\r\n"; var_dump($content); echo "</xmp>"; 
    if ( in_category('First') ) {
    $content.= "<p>Custom text 1</p>";
    }
    if ( in_category('Second') ) {
    $content.= "<p>Custom text 2</p>";
    }
    }
    return $content;
    }
    add_filter ('the_content', 'text_after_content');
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom text below posts not working’ is closed to new replies.