0

I am creating my own theme and was wondering if there is a way to remove get_template_part() when you're on a specific page? For example:

<?php
if ( is_page('blog') ) {
 [Remove]get_template_part('the', 'blog');
}
?>
1

you could do it the opposite way:

<?php
if ( !is_page('blog') ) {
 get_template_part('the', 'blog');
}
?>

this would make it show up on all pages but the blog.

  • Gosh @rudetek. I feel so retarded right now. Thanks for your help. – Leroy Mar 9 '17 at 21:44
  • ha. no worries. would you mind marking it as answered? (check box to the left of the answer) – rudtek Mar 9 '17 at 21:45
0

So I can think of a couple of ways at least:

  1. You could make a new template in your theme, that doesn't use get_template_part, and assign that template to pages you create in WP. (solution for multiple pages of the same type)
  2. You could create a single-use template for just this page, (based on its slug) so that just this page has a special template that doesn't use get_template_part

Does that answer your question?

  • yes. I am aware of these methods. However, my curiosity is the one that needs to be fed. I want to know if there is a way of doing it in the method I am talking about. – Leroy Mar 9 '17 at 21:09
  • I'm not sure what method you are talking about then, sorry? Which method are you talking about? – MacPrawn Mar 9 '17 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.