WordPress.org

Ready to get started?Download WordPress

Forums

Altering get_template_part (1 post)

  1. bongkph
    Member
    Posted 1 year ago #

    Hi there.

    In my single.php file, I have this code to call the contents of a post.

    <?php get_template_part( 'includes/loop' , 'single'); ?>

    Can I alter it to show different contents/templates based on the given tags of posts?

    Say, I want to get the template loop-cat (includes/loop-cat.php) if post tag is 'cat'. Same goes for the other template. Most propably I will have at least 10 templates to show.

    I dont want to merge them in a sinlge loop file because I am worried that the file may get heavy.

    Please help me. If there are other better ways to call different templates for different tags, please let me know.

    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Topic