• I want to know if someone know how I can put some content inside the post if it’s using the tag X (Y, etc).

    I thought using something like “<?php is_tag($slug); ?>”, but with that the single.php will be too long if I make more “if” inside the posts..

    Anyone know a better way to do that or a simple way?

Viewing 5 replies - 1 through 5 (of 5 total)
  • has_tag() http://codex.wordpress.org/Function_Reference/has_tag

    depending on the content that you want to add inside a post (where exactly ?), you might be able and use a filter function which would be addded in functions.php of the theme;
    example code:

    add_filter('the_content', 'inside_post_addendum');
    function inside_post_addendum($text) {
    global $post;
    if( has_tag('slug', $post) ) :
    /*do something with the post content, i.e. $text*/
    endif;
    return $text;
    }
    Thread Starter Dennis

    (@altermann)

    I’m thinking something about post header or post footer.

    something about post header or post footer.

    this information is not really exact enough to make useful suggestion;
    seems that a filter function is not the solution;
    however, you can add as much code (conditional statements) to single.php as you need; there is no reason to keep the template short.

    can you post an example?

    what theme are you using?

    Thread Starter Dennis

    (@altermann)

    Hmm, something like this:

    if post is on tag “WordPress” add “This post is an serie about WordPress” in the post header (before the post content)

    Thread Starter Dennis

    (@altermann)

    Maybe something like text replacer will be great too. Found the “Text replace”, but only works to replace 1 line of text :~

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post content if is tag X (or Y, etc)’ is closed to new replies.