-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misplacement of loop? #1582
Comments
Hello and welcome to the wonderful world of WordPress with Roots! This isn't an issue with the theme :) Questions like this are best directed at the user forum over at discourse.roots.io. Reading the docs for get_template_part() may shed some light on it for you though. |
I am still wondering why for search, the loop is placed in the "main template" (lacking terminoligy here) As well as in the page "main template" But is moved to the "sub template" for single. Seeing the loop in the "main template" for search.php and page.php made me assume it also had to be in single.php, so I added it there, not expecting it to loop again in the "sub template". Now I have removed the loop from the "templates/content-single.php" and moved it to "single.php" <?php while (have_posts()):
the_post();
if (has_category(2)) {
get_template_part('templates/content-member', get_post_type());
} else if (has_category(4)) {
get_template_part('templates/content-promotion', get_post_type());
} else {
get_template_part('templates/content-single', get_post_type());
}
endwhile; ?> So besides making it more similar to search.php and page.php, it also allows for using a different template based on some condition (which is what this theme is all about?) Looking at the get_template_part function (thanks for the links btw) it seems that it should actually be something like this: <?php while (have_posts()):
the_post();
if (has_category(2)) {
get_template_part('templates/content', 'member');
} else if (has_category(4)) {
get_template_part('templates/content', 'promotion');
} else {
get_template_part('templates/content', 'single');
}
endwhile; ?> Will use the discussion board for future questions. Looking forward to your response. |
fixed in sage 9 b24eb36 |
Hey there, it looks like this loop:
https://github.com/roots/sage/blob/master/templates/content-single.php#L1
should be moved to here:
https://github.com/roots/sage/blob/master/single.php#L1
Otherwise if the content-single is used in search.php or index.php, it will become an endless loop?
First days with wordpress so I am likely wrong...
The text was updated successfully, but these errors were encountered: