Where do I find the loop?
-
Don’t know where to put this question.
How do I place another function inside a php-loop?
A “comment-counter” inside a loop of “latest posts”.
Where do I find this loop? I feel like I’ve tried to place the code everywhere.
And is it the whole code, or just til function-call I have to place in the loop?
-
http://codex.ww.wp.xz.cn/Main_Page
Codex has all the info on The Loop π
http://codex.ww.wp.xz.cn/The_Loop
For 1.5 users, the absolute beginning of a post Loop is here–consider it the green light for posts:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>The logic of this line works like this: “Do we have posts to do something with? Well if we do, for each post…” This could be considered The Loop Proper, in that this is where a post’s components are displayed. A comment counter would definitely go in here.
The Loop continues on with a Yield sign put in so WordPress can stop and think:
<?php endwhile; else : ?>This is asking “If we haven’t any posts based on what was queried, what then should we do?” Typically an error message would go here.
Then, finally, the Stop sign for The Loop:
<?php endif; ?>The counter is the write in like this:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> : <?php mdv_comment_count(); ?>
or ?
Don’t understad it…. π
I use this:
http://dev.wp-plugins.org/file/recent-posts/branches/wp-1.5/recent-posts.php…and this…:
http://dev.wp-plugins.org/browser/comment-count/branches/wp-1.5/But where do I put the last one, if I want it to count comments for each post….?
It can go anywhere in The Loop, but note this shows the # for all comments on your site (and will work outside The Loop as well as in):
<?php mdv_comment_count(); ?>This would be used for comments only on a post (and in The Loop):
<?php mdv_comment_count(FALSE); ?>See the (short) readme on the plugin:
http://dev.wp-plugins.org/file/comment-count/branches/wp-1.5/read_me.txt
I’ve been driving myself crazy with this question for more than one week now. I understand what I am looking for, but I don’t understand where I am supposed to look for The Loop? Is it in one of the theme files? If so, which one? The stylesheet? The header template? I’m sorry for posting what might seem like an idiotic question, but it’s the only way I will learn π
Places to find The Loop (in 1.5) are in a theme’s templates:
– index.php
– single.php
– home.php
– archive.php
– category.php
– page.php
– author.phpNot all themes will have all these templates (or need them), but each type of template listed will make use of The Loop. One additional template to be concerned with:
– comments.php
The loop here, however, is a bit different. It starts here:
<?php foreach ($comments as $comment) { ?>“Yields” here:
<?php } else { ?>And finally ends simply with:
<?php } ?>Thank you so much for that. I appreciate the help.
Still don’t understand where to put the line for the counter, if i place it anywhere inside the <?php …. from the “recent posts”, then it will not work on my site.
If I put the <?php mdv_comment_count(FALSE); ?> after the <?php mdv_recent_posts(); ?> then it only counts for the first post…I’m having a problem with the loop myself.
If you feel like looking at my site, it’s here…
http://bradydale.thistoowillpass.com/
The loop at the bottom wants you to go the “Next Page” here:
http://bradydale.thistoowillpass.com/wordpress/bradydale/index.php?paged=2
And previous page here:
http://bradydale.thistoowillpass.com/wordpress/bradydale/index.phpOnly there is nothing at either of those places. The problem is the subdomain, I guess…
Where it should go, at least for the next page, is here:
http://www.thistoowillpass.com/bradydale/wordpress/index.php?paged=2
and this works as well (and probably is easier… but who knows?)
http://bradydale.thistoowillpass.com/index.php?paged=2So how do I make that happen? I’ve looked around but I can’t really figure it out. A problem I frequently find on the Codex is their is a description of the code you need but not where to find it. Hmm…
Thank you so much for your help!
BR
by the way, I just relooked at this post and the edges got cut off. What I posted did finish with “paged=2”
Thanks…
BRIt seems you have a “fake” subdomain – so it will never work.
By fake I mean it is redirected to a subfolder. WP won’t work in that way.I don’t know much, but my instinct tells me that’s not right.
If bradydale.thistoowillpass.com
effectively just looks at
http://www.thistoowillpass.com/bradydale/wordpress/index.php
(which it does)
isn’t it simply just a matter of changing some of the code so it keeps looking at iterations of that?
…php?paged=2, etc.???If bradydale.thistoowillpass.com
effectively just looks at
http://www.thistoowillpass.com/bradydale/wordpress/index.php
(which it does)That’s the problem.
A real, normal subdomain “looks at”
http://bradydale.thistoowillpass.com/wordpressNow, you have once:
the redirect for your fake subdomain
and secondly the two URI values set in the Options > General.If all those things point in 3 different directions (URLs) WP gives up.
The topic ‘Where do I find the loop?’ is closed to new replies.