WordPress.org

Support

Support » How-To and Troubleshooting » $all_tags adding extra h1 tag

$all_tags adding extra h1 tag

  • I am trying to figure out why extra <h1 class=”category-title”> are being inserted into the markup.

    here is the code/loop I am using inside of archive.php:

    elseif (is_archive('the_tag')) {
    
    	  if ($all_the_tags);
    	    $all_the_tags = get_the_tags();
    	    foreach($all_the_tags as $this_tag) {
    		    if ($this_tag->name == "test1" ) {
    		      echo '<div id="cat-title-logo" ><img alt="test1" src="' . get_bloginfo('template_url') . '/imgs/logo-test1.jpg"/></div><h1 class="category-title">';
    		    } else if ($this_tag->name == "test2" ) {
    		      echo '<div id="cat-title-logo" ><img alt="test2" src="' . get_bloginfo('template_url') . '/imgs/logo-test2.jpg"/></div><h1 class="category-title">';
    		    } else {
    			    // it's neither, do nothing
    		      echo '<h1 class="category-title">
      <!-- not tagged as one or the other -->';
    		    }
    	    }
    	    single_tag_title('Tag: ');?>
    
    	</h1>

    The HTML markup looks like this:

    <h1 class="category-title"></h1>
    <h1 class="category-title">
        <div id="cat-title-logo"><img src="http://www.foobar.com/wp-content/themes/blah/imgs/logo-test1.jpg" alt="test1"></div>
    </h1>
    <h1 class="category-title">Tag: test1</h1>

    as you can see it’s inserting 2 extra h1 tags, 1 empty one, and 1 wrapping one. Is this part of core functionality or something?!?!?!?

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘$all_tags adding extra h1 tag’ is closed to new replies.