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)

0
votes
1answer
682 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
342 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
390 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
816 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
464 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 = ...
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 ...
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
266 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
388 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'); ...
1
vote
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
606 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
654 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
685 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
701 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 ...
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' ...
1
vote
2answers
721 views

query_posts() ALWAYS displays something?

OK, I'm using posts_query() to display posts. The problem is, at least in my case, posts_query() always outputs something. For example: <?php $paged = (get_query_var('paged')) ? ...
2
votes
2answers
3k views

$post>ID displays wrong post ID

I've asked a question about listing all sub-pages before: Listing all sub-pages? But all the questions were wrong. Anyways, I have now simpler question. global $post; echo $post>ID Works ...
5
votes
1answer
5k views

Sort pages in loop by admin's page attributes order field?

Is it possible to sort pages in the loop using the admin's order field (under page attributes)?
0
votes
1answer
3k views

WordPress: query pages except remove one page

I'm currently running this query to get pages (not posts) from the site section: query_posts("post_type=page&post_parent=6"); I'd like to remove one page, 271, from this query. Based on this ...
4
votes
5answers
5k views

How to return results of a get_posts() in explicitly defined order

I'm trying to create a loop of explicity ordered posts, for example: <?php $args = array( 'include' => '1,3,8,4,12' ); ?> <?php get_posts( $args ); ?> The results are ...
1
vote
3answers
323 views

Grossly inefficient wordpress loops!

I'm working on a site at the moment for an orchestra. The various members need to be listed, according to their instrument. The members have a custom post type of biography and I'm capturing the ...
0
votes
2answers
713 views

Show a Category X's custom post type on Category X archive page?

I created a custom post type "landing_page" to hold content I want to display on the top of category archive pages. So for each category, I have one landing_page entry tagged with that category. What ...
0
votes
1answer
271 views

Shortcode leaves no space for other elements?

I've created my own shortcode. I'm unable to share the code unfortunately ;/ When I use it on my pages it behaves strange. It always has the highest priority. I mean something like that in page ...
1
vote
4answers
219 views

Dynamic Landing Page

I have a site with posts going back 5 years and I want to create a couple landing pages to highlight groups of posts. For example, I want to create a page about "blue widgets". The page should include ...
0
votes
2answers
699 views

Get paged outside of loop?

Is it possible to get paged outside of the standard WP loop? I already use this inside the loop: <?php if ( $paged >= 2 ) { ?> Some text for the 2nd page on up <?php } ?> But I'd ...