• Resolved ADN69

    (@adn69)


    Hello,
    I have a question about how to make a custom php code.
    This is my php code that calls the tags:
    <?php if (get_the_tags()) the_tags(__('Tags: '), ', '); ?>
    And what I want is : if a defined tag (sports) exists in my post tags, include a sport banner, if another defined tag (life style) exists in my post tags, include a life style banner.
    I really need a help, please!
    Thank you in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter ADN69

    (@adn69)

    I have found the solution here: http://codex.wordpress.org/Function_Reference/get_the_tags
    And my code is something like this :

    <?php
    $all_the_tags = get_the_tags();
    foreach($all_the_tags as $this_tag) {
    	if ($this_tag->name == "Sports" ) {
    ?>
    
    <p><img src="sports.gif"></p>
    
    <?php 	} else if ($this_tag->name == "Life Style" ) { ?>
    
    <p><img src="life-style.gif"></p>
    
    <?php
     	}
    	}
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a custom banner per tag’ is closed to new replies.