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)

13
votes
3answers
11k views

Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function: <?php $sixtydays = date('Y/m/d', ...
4
votes
1answer
2k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
4
votes
5answers
10k views

How to split a loop into multiple columns

If I have a loop running from a category query like : <?php $the_query = new WP_Query('cat=1&showposts=50&orderby=title&order=asc');?> <ul> <?php while ...
4
votes
1answer
260 views

How to return loop contents

At times, I need to return the output of a loop (usually with WP_Query like in this example) for use in a shortcode or with a filter on the_content. The following code that uses object buffering ...
6
votes
1answer
2k views

How can I fetch loop of post titles via AJAX?

I have a list of the most recent post titles in sidebar.php. Here is an example of how that code looks: <?php $args = array('posts_per_page' => 20); ?> <?php $sidebar = new ...
2
votes
1answer
1k views

Is it possible to define a template for a custom post type within a plugin independent of the active theme?

I'm writing a plugin to manage data about open-source projects. I developed an object model and have successfully created all custom post types and taxonomies, as well as implemented the correct ...
2
votes
2answers
3k views

WP_Query and next_posts_link

I cannot figure out how to make next_posts_link() work within my custom WP_Query. Here is the function: function artists() { echo '<div id="artists">'; $args = array( 'post_type' => ...
2
votes
2answers
1k views

“pre_get_posts” firing on every query

How can I change arguments for the main query only, and not affect other queries? add_filter('pre_get_posts', 'custom_post_count'); function custom_post_count($query){ ...
3
votes
2answers
182 views

Do I need to use The Loop on pages?

I'm writing my first WordPress theme and have a question about the use of The Loop in page templates. The page templates I've looked at all follow basically the same pattern (example from Twenty ...
2
votes
1answer
437 views

Multiple Loops Homepage?

I have been pretty impressed with the recent redesign at WebDesignerDepot and I am curious about the mechanics of their homepage. I like how they have featured post sections that break up the monotony ...
1
vote
3answers
424 views

Using the loop inside admin

I have the following issue: I am creating a custom-meta-box for the user to add custom fields in a friendly way. I want to generate a drop-down box with all posts that fall under category 10. I have ...
0
votes
1answer
462 views

How to make multiple Column in archive Page?

I want to create multiple column on archive page but dont want duplicate posts please have look examples http://www.firstpost.com/category/business ...
0
votes
2answers
896 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) ); ...
1
vote
1answer
3k views

Multiple WP_Query loops with Pagination

There are a few other questions about this (and WP_Query pagination seems to be a huge question for a lot of people) so I'm trying to narrow down exactly how to make it function. I'm able to create a ...
4
votes
1answer
447 views

How-to exclude terms from the main query the most performant way?

This Q is a follow up to this answer on the Q: "How to exclude a specific term for the search?". 4 ways to filter out posts that have a specific term Type | Pro | ...
3
votes
2answers
3k views

Pagination with WP_Query is buggy - working for some pages, but not the others

I'm having a very peculiar bug with pagination :( I'm trying to display 4 posts per page for a category with slug "lastest-news". The pagination function seems to work correctly. There are 33 posts. ...
2
votes
1answer
470 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 ...
1
vote
1answer
172 views

Add inline HTML to posts published within last 24hrs

Basically I'm looking to add this line of code to posts published within the last 24hrs: <span class="new">New!</span> When the post is over 24hrs old, remove the inline HTML element. ...
1
vote
1answer
554 views

posts_per_page & pagination conflict

I have a custom query to display my custom post type. posts_per_page set to '5'. In admin post per page set to '10' (settings => Reading => Blog pages show at most 10 posts) My template lists 5 posts ...
1
vote
3answers
300 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
2k views

Can i merge 2 new WP_Query($variable) 's?

I am running a multisite network and i have setup a sql query that uses swith_to_blog(); and queries the posts. Is there a way that i can declare the query inside a new WP_Query and actually merge ...
3
votes
1answer
976 views

How to add author details in the post sidebar?

I would like to add author details in the sidebar instead of bottom of the post? Can anyone tell me how to do that? As of now i'm using like this in the loop <?php $curauthor = ...
3
votes
4answers
4k 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 ...
2
votes
3answers
6k views

How to Change Loop to Order Posts by Views (using wp-postviews plugin)

I hope somebody would be kind enough to help. I currently have a page that orders all of the posts by comment count, but I want to change the loop to order the posts by view count. I have installed ...
1
vote
2answers
540 views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > ...
1
vote
3answers
707 views

Custom post type not displaying content from single-{custom post type} page

I am trying to create a custom post type with taxonomy and a shortcode for my custom search in a plugin.When I activate my plugin I see my CPT and taxonomy on dashboard. But when I publish the post I ...
1
vote
2answers
1k views

List all posts in Custom Post Type but group dynamically by Custom Taxonomies

I have a custom post type named "Resources" which has a Taxonomy named "Types." I have it manually pulling each term which isn't the most elegant solution and every time there is a new term added, I ...
0
votes
1answer
84 views

Wordpress Alphabetical Glossary close div in loop

wrote this piece of code to make a alphabetical glossary and it works, but there is 1 problem. I don't know how I can end a set of posts with the same first letter. This code looks at the first ...
0
votes
2answers
79 views

Identify the page being shown while in The Loop

In my loop, I'm trying to set it so that certain text is displayed on certain pages, if there are no posts to display. I thought this would be simple, using is_post(), but it seems that this function ...
0
votes
1answer
132 views

Order custom posts by taxonomy?

I have the following custom post types: books, documents, examples, guidebooks, onlineaids. They were generated by the following code: ...
0
votes
1answer
134 views

Style every four posts differently [duplicate]

Possible Duplicate: How to mark every 3rd post Is it possible to style every four posts differently? I mean something like this: <div class="row"> <div>1st post</div> ...
0
votes
1answer
163 views

Using jQuery .after inside loop

I have a bit of javascript that will dynamically add a static post to a loop. The script uses the jQuery 'after' method and on a static page it works beautifully but when inside the loop I don't get ...
0
votes
2answers
872 views

WordPress Loop Through Particular Pages

I have the following code setup as a page template and assigned to a page: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php ...
0
votes
2answers
260 views

Stepping through a foreach loop - adding +1 to the end of it so next time it loops it starts on item 2

I'm creating a custom Google map that plots multiple markers. View the link as it will make it easier to explain what is happening and what I want If you click on each marker it shows company names ...
10
votes
3answers
2k views

Display all posts starting with given letter?

I'm trying to build Wordpress based dictionary, basically it will have 26 pages (one for each letter): A B C ... X Y Z And every page will display all posts starting with given letter, so after ...
4
votes
5answers
3k 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 ...
2
votes
1answer
330 views

Find most recent authors

What I'm looking to do it get the 16 latest posts from 16 different authors. In other words there would be the 16 latest posts, but no one single author would have more that 1 post on the page. The ...
6
votes
3answers
11k views

Get post content from outside the loop

Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page.
5
votes
5answers
8k views

Display all posts in a custom post type, grouped by a custom taxonomy

I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the ...
1
vote
1answer
210 views

Show newly added posts since last user login time /date

I'm looking for a solution to create a custom loop which will only display the last added/ modified posts since the last user login to the site. It shouldn't be that complicated doesnt it ?
2
votes
2answers
863 views

Broken pagination

Well I'm here again with almost the same problem as I had in this post three weeks ago, but let me explain what has happened since then: I was originally using one loop to display the most recent ...
1
vote
1answer
1k 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. ...
1
vote
3answers
6k 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
1answer
74 views

What exactly defines a Main Loop and a Secondary Loop?

My assumption is that the main loop is always the first loop and you're always supposed to use query_post? Is this correct? Then whenever you you need to feed in some arguments to get a different set ...
0
votes
2answers
1k views

How to retrieve “sticky” post outside the “loop”?

I need to display the "sticky" post in a section that is outside the "loop". Can someone tell me how to do this?
6
votes
2answers
605 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 necessarity, wordpress will turn to ...
3
votes
4answers
2k views

How can I create an alternative home page?

I'm working on a site which has a fully customized front page. Now I'm asked to add a more classic looking blog type page which will be reacheable at http://domain/blog. I tried creating a custom ...
2
votes
2answers
214 views

Auto Refresh Post List after X seconds

i'm new in wordpress, and i really need a help here. My main site, list the resume (excrept) of all posts, with pagination. But when a user publish a new post, the only way to see it on the main page ...
2
votes
1answer
2k 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 ...
2
votes
1answer
9k views

wp_pagenavi() with custom wp_query()?

<?php /* Template Name: Projects */ ?> <?php get_header();?> <section id="content"> <section id="main"> <?php $loop = new ...