• Is there any way to create a tag.php template that gets applied if the blog post belongs to a specific category? I’m using tag-slug.php for product brandnames that belong to a wordpress category and really need to find a way to have one tag template rather than using tag-slug.php. Hope this makes sense ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Probably could use a loop like this

    <?php
        $categories =  get_categories('child_of=4');
        foreach  ($categories as $category) {
    
           echo '<h2>'.$cat_img.$category->name.'</h2>';
            // start a list of posts
            echo '<ul>';
            foreach (get_posts('orderby=post_date&category='.$category->term_id) as $post) {
                setup_postdata( $post );
    
            // echo out the results into a list item
                echo '<li class="recipelist"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.  $speaker_name . $scripture.'';
            }
            // close the list
            echo '</ul>';
        } ?>

    Where it says $categories = get_categories('child_of=4');
    you’d change the number to the specific category number.

    Though I’m not sure what needs to be added to make it exclusively for the tag you selected

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create a tag template for a specific category – is this possible?’ is closed to new replies.