The core of the WordPress query, the loop offers an easy way to access post information and display it on your website.

learn more… | top users | synonyms (3)

1
vote
1answer
2k views

Show scheduled posts in archive page

I'd like my archive.php page's daily view (is_day) to display scheduled posts (post_status=future). For example, if I go to mysite.com/2011/05/20 I would see all posts scheduled to appear on May 20. ...
0
votes
2answers
671 views

Recent posts per category loop?

I need a loop/plugin/widget to display latest posts from the category the user is browsing and at the same time if he visits the home page, it should show posts from all categories (not a specific one)...
0
votes
3answers
749 views

While in “the loop”, detect if a post is the most recent

While inside "the loop" in WordPress, is there an easy way to detect if a post is the most recent? A Usage Example: I want to make the first post output an H1 for the title instead of an H2. Or I want ...
0
votes
1answer
7k views

How to get The Loop working with $wpdb->get_results()

I am doing a rather complicated custom query on a blog's front page, and trying to show the results using The Loop as shown here: Displaying posts using a custom SELECT query The query filters posts ...
0
votes
4answers
3k views

Displaying multiple post types on home page

I've read several examples of how to do this but I still can't get it to work - each time I use get_posts() it seems to only keep and display the first set of results. loop.php function home_index()...
0
votes
1answer
1k views

Wordpress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page

Hey everyone. I'm not sure if what I'm experiencing is a result of a bug (due to the recent upgrade to 3.1.2) or poor coding. Ever since i upgraded to version 3.1.2 ive been experiencing a problem ...
0
votes
1answer
223 views

Loops for cat links not looping for wordpress site

I have this code and all the vars pull in but the latest news is not showing up and the subscribe link is not dropping anything. any ideas? Everything else works like a charm. <div class="...
0
votes
2answers
155 views

the_post() in RSS feed

I'm got an issue here that's stumping me. I'm trying to create a custom RSS feed using add_feed(). The feed seems to have been created successfully, but I'm quite stuck on some bug in the feed ...
1
vote
1answer
334 views

Show css depending on activity type in BuddyPress activity-loop [closed]

I was wondering if anyone knew of a way to show specific styles to the activity loop depending on the activity type? This is what I had an idea of: function mycustom_act_type() { if ('...
4
votes
2answers
14k views

Get post by page name or slug

I know this is very avant-garde, but bear with me. I've read that one is able to query a page by the page/post name or slug. I'm trying to do this because I need information from a page with a similar ...
0
votes
1answer
687 views

WP_Query - Adding “offset” posts to the end of the loop

I'm trying to create two queries. In the first query, I will, for example, display 6 posts, in a given order. In the second query, I want to display the same 6 posts, but "offset" the first 3 and ...
0
votes
1answer
348 views

How / where is the wp_query object created for RSS feeds?

Looking at the code in feed-rss2.php and feeds-rss2-comments.php, after the header preamble, we have a Loop - eg in feeds-rss2-comments.php: if ( have_comments() ) : while ( have_comments() ) : ...
0
votes
2answers
393 views

Loop from another WP site onto mine

What i'm trying to achieve is bringing a loop from one WP site into another WP Site. I used this method to get the loop into an external php file (which all works fine, the results show) <?php ...
0
votes
1answer
4k views

Sub-loop / nested loops Best Practices

I'm trying sort through the morass that is WP documentation, and just need someone to clear up the use of the term "The Loop" and how it relates to subloops. My understanding of "The Loop" is that ...
0
votes
1answer
959 views

Stomping WP_Query in author archive to facilitate pagination with custom queries

I am using get_posts and get_comments to build several loops on the page, at which I am having some issues in pagination. I have the global posts per page option (Settings > Reading) set to 10, and ...
1
vote
2answers
1k views

Pagination gives extra page with no results

I'm trying to implement pagination on a category page. The pagination is working, but now for some reason the pagination plugin I'm using is noting one extra page of results, when that page is ...
1
vote
2answers
2k views

Adding 'current_post_item' class to current post in the loop

I'm using a loop in the sidebar of my site to show all the posts that are in that category. Now I'd like to include a 'current_post' class to the current post that is being displayed to style that ...
2
votes
1answer
821 views

How to dynamically build a multiple taxonomy query loop within a post type's single loop?

This question is a little different then the others floating around here. The most similar one is "How to get the parent's taxonomy ?". I have a music cms setup that utilizes two post types: album ...
1
vote
1answer
466 views

PHP loop that selects posts with a particular in-post option

Im trying to build a Featured post slider to show any post that i mark as a "featured" (with a in-post option) regardless the category or tag type... Im new to wordpress and although I understand a ...
0
votes
1answer
154 views

All post ids are the same after this query but rewind_posts() does not seem to work here?

I'm executing a query inside of header.php which is apparently resetting the $post object so that all pages are getting the $post->ID of the last element in this loop. $mypostsheader = get_posts(...
0
votes
1answer
602 views

looping though custom post types and only return results in a given taxonomy

I am creating a WordPress theme for a record label. One aspect is the video gallery. I created the gallery using a custom post type called 'videos'. The code below is what I placed in my functions....
0
votes
1answer
484 views

Problem with WP_Query loop and search term

I have a custom query to display random posts in my sidebar like this: $newQuery = array( 'post__in' => get_option('sticky_posts'), 'post_type' => 'ad_listing', 'posts_per_page' ...
3
votes
1answer
3k views

Using the Loop to show all levels of subpages under a parent page? Halfway there

I have a need to make the Loop run through all of the children of a parent, all of the children of each child, etc. The reason I need the Loop instead of a listing tag like wp_list_pages is so that I ...
1
vote
2answers
9k views

How do I get the title of a category in a custom loop?

I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list. <ul class="subcats-list"> <?php $weightloss = ...
0
votes
1answer
2k views

Metadata in loops

I have a standard Wordpress loop displaying items: $loop = new WP_Query( array( 'post_type' => 'images', 'orderby' => 'menu_order', ) ); while (...
4
votes
3answers
7k views

Modify main WordPress loop with a parse_query filter

I am trying to modify the main WordPress loop on my category pages like so: add_filter('parse_query', 'my_modified_query'); function my_modified_query( $q ) { if (!is_admin() && ...
0
votes
1answer
147 views

strange parse error when including a loop template within another template

I have a loop template called loop-event-details.php where I have code to display each event. My main page template is called events-page.php. I use the following code to include the loop template: ...
0
votes
1answer
138 views

List categories of a post hierarchically?

Let's say I got the following categories: Style | + Shoes + Pants If I make a post and put it in the Style and Shoes category, it will list them alphabetically instead of hierarchically. So ...
0
votes
1answer
267 views

Creating mulitple loops in a sub-category page

I have a main page that consists of 7 categories being output by wp_list_categories, each li specifically includes one ID. These categories are directed to a category-page.php specifically built for ...
0
votes
1answer
2k views

Skip 5 latest post while paging?

In the index.php page, I need to skip 5 posts (the last 5 posts in the blog). I use the WP-Paginate plugin, but all pages show the same. I'm using offset=5, this is my code: <?php $paged = (...
0
votes
1answer
389 views

Error while excluding a post from another loop (using its ID)

I'm trying to get the ID of a post in the first loop (using <?php $postid = get_the_ID(); ?> ) and use it in a variable ($postid) to exclude that very post from a second loop (using ...
1
vote
1answer
127 views

It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?

This is the code: <?php get_template_part( 'pagination', 'bbp_replies' ); ?> <?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2'); ?&...
2
votes
3answers
10k views

Display thumbnail only on the very first post in the loop?

What's the best way to use <?php the_post_thumbnail();?> in my loop BUT only show a thumbnail on the FIRST post? Meaning, only the first post in the loop will have it's image shown? Here is an ...
0
votes
2answers
105 views

How to tell if all posts are only in one category?

I have a category.php page which redirects users to a certain template page if the article in the output is in a category. However, I am seeing that if I have say 10 articles,and only one is in the ...
0
votes
1answer
609 views

“Order” doesn't work in custom loop?

I have a custom loop (used in a shortcode) that lists items from custom post type. Everything works fine but "order" for posts doesn't work, no matter what I type as order attribute on post page - ...
2
votes
2answers
1k views

Fastest way to loop through all posts?

I need to run a background process in a plugin that does some work on ALL the posts in a person's database once the plugin is installed. I'm very new at working with wordpress so my research has shown ...
0
votes
2answers
3k views

Exclude current post from loop

I have a custom post type for accessories. When you view the post it also shows related posts. It looks great, but it also shows the current post within related posts. Is there a way to exclude the ...
2
votes
1answer
657 views

Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !

What I want to do is a loop like this is something like this I'm really sorry but its hard to format here! I going to put this short url http://pastebin.com/dEdKzgJz so you can see it better... Can ...
5
votes
4answers
10k views

How do I exclude a custom taxonomy from the post loop

Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer. I know it can be ...
0
votes
2answers
2k views

Include multiple page ids in loop

Haven’t slept in about 30 hours now, can someone please help as the below code doesn’t work, it just displays all posts etc :| <?php $args = array ( 'page' => array(139, 54) ); $...
0
votes
1answer
392 views

get post images to link to external sources

I'm buiding a site that lists the most recent posts on the front page, the site is a recompilation of interesting articles and images so it doesn't make sense to link to the individual post. I ...
1
vote
1answer
1k views

Dynamic sidebar nav with current page highlighting

My sidebar loops through all of the child pages based on the parent page. For example, if you're in the "About" section you'll only see "About" child pages in the sidebar. My problem is that I have ...
0
votes
1answer
688 views

Last post in loop - custom post types

I added the below code to my index.php and it's working fine. Then I added it to my type-[post_type].php file and it's still displaying the code for the last post on the page. I can't figure out why. ...
0
votes
1answer
159 views

Not Found when using activity stream as front page with BuddyPress

I'm trying to create a Thematic child theme that uses BuddyPress. First, I tried using BuddyMatic -- which currently doesn't work with WP3. Next, I tried the BuddyPress compatibility pack -- which ...
2
votes
2answers
2k views

Content/Excerpt length control for a specific loop?

Is it possible to control the length of the content or excerpt for a specific query/loop? I have come across the following code, but this changes the length for all excerpts, I want it focused on a ...
1
vote
2answers
372 views

Multiple loops on the same page removing post tags

I am trying to use two loops on my page, one to get the current page's content and so on, and another to get all of the posts of a specific category. When I do that, all of the tags for the current ...
0
votes
1answer
2k views

How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?

This is the topic loop of the bbPress plugin. How can I make it stop when it reaches two posts? (Topics custom post types)? <?php /** * Topics Loop * * @package bbPress * @subpackage Theme */...
0
votes
2answers
417 views

Including post data in a sidebar occurring outside of and before the Loop

I'm having problems setting up a single WordPress template page to display post data outside of the Loop. The page has a left sidebar in which I want to display post meta data, tags and navigation ...
6
votes
2answers
702 views

Do we still need to include a “if (have_posts())” in templates?

I include this logic in my template all the time if ( have_posts() ): //show content else: //show content not found endif; But recently I began to doubt its necessity, WordPress will turn to 404....
0
votes
2answers
1k views

Multiple loops with / without sticky posts and different post limits

I am having trouble with multiple loops and sticky posts in wordpress. The first loop I just want all the sticky posts. <?php query_posts(array('post__in'=>get_option('sticky_posts'), 'cat' =&...