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)

3
votes
1answer
1k 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
2answers
249 views

Identify which loop you are hooking into; primary or secondary?

What is the most efficient way to determine which loop I'm in? I have a few plugins that alter the query by hooking into various parts of WP_Query::get_posts(), through the usual suspects, ie ...
3
votes
2answers
10k 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 ...
3
votes
3answers
65 views

Display posts the match taxonomy term linked from wp_list_categoies?

This should be simple, but it escapes me. I have a custom post type and a custom taxonomy. The taxonomy is named "asset_type" and the slug is "type" I am using wp_list_categories to provide a ...
3
votes
1answer
92 views

How to show Y number of custom posts after every X normal posts?

I have a loop within a loop. I figured out how to show all or X number of custom posts after Y number of normal posts. I also figured out how to show 1 custom post after every Y normal posts. How do I ...
3
votes
1answer
386 views

rewind_posts() - what actually the use of it, and where using is required or preferred?

The incomplete Codex about this, says very simply: rewind_posts(): Rewind the loop posts. As per this WPSE thread, with Eugene Manuilov's answer, I got: <?php // fetch first post from the ...
3
votes
1answer
399 views

Order posts by ID in the given order

In the back-office of my theme, the users can choose which posts to display in the front page, and they can also choose in which order the selected posts should appear. I have tried like this: ...
3
votes
1answer
2k 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 ...
3
votes
2answers
3k views

Display list of Sub-Categories and the posts they contain, within one main Category

I've found tons of code and plugins to do various things; from show posts for specific cats, subcats of a cat, etc.. BUT, I cannot for the life of me find, nor do I know the WP API well enough to do ...
3
votes
1answer
373 views

how do I group content in magazine-style 'issues'?

I am building a website for a magazine. It won't carry the whole content of the mag, just a teaser article or two from each issue. I need to have a page for each issue that features these articles, ...
3
votes
1answer
4k views

Get the children of the parent category

I'm trying to get all the children categories to display in this loop but I'm struggling with the code. This is what I have so far. <?php $args=array('orderby' => 'name', 'order' => 'ASC'); ...
3
votes
1answer
168 views

Add 20yrs to post date, and then query

I would like to know if anyone knows a way of adding a timeframe (say 20 years) to the datestamp on a set of posts, and then running a query on the loop which uses the new date? Basically what I want ...
3
votes
1answer
29 views

How to place a loop within another loop?

I have two loops setup using WP_Query: $latest and $popular that I'm working to setup in this example layout: Latest                        ...
3
votes
1answer
50 views

Add Incrementing ID to each paragraph in the_content

I need to loop through each paragraph in the_content and add an ID to each paragraph with an incremental value. function incrementparagraphs( $content ) { for ($i = 0; $i <count($content); ...
3
votes
1answer
61 views

Changing behavior of the loop twice in one page

I'm trying to set up a wordpress blog. I have one loop with featured posts, that pulls from the 'Featured' category and displays a slider of prominent posts. Below that, I have the regular feed of ...
3
votes
1answer
105 views

Wordpress “Loop” with large set of results

I'm not sure the appropriate terminology but I have a wordpress "loop" for a custom post type that has roughly 300 results that all get displayed on a single page (no paging). The causes an enormous ...
3
votes
2answers
232 views

How do I prevent one of two multiple loops from repeating on a second page?

I have a page with multiple loops, but the first loop repeats on the second (or Older) page. I want to keep the formatting but stop the post from repeating. You can see the problem here: ...
3
votes
1answer
100 views

How can I create a loop to build slides based on multiple categories using Coda Slider

I'm using a loop to generate the slides I need for a Coda Slider slideshow. The slides should be pulling the most recent post from 5 different categories. The problem I'm having is that it's pulling ...
3
votes
1answer
2k views

how to display full post with pagination on home page

I am using the 'Hatch' theme. I'm familiar with HTML/CSS but not with WordPress, first time working with this. I have my homepage showing recent posts and that's good. However, I want to make a ...
3
votes
1answer
165 views

How should I intercept the main query and inject custom join / order by / group by criteria

I have a CPT that is a member of two separate taxonomies. On the taxonomy archive page for one of the taxonomies, I need to further group and sort on the second taxonomy like so: ...
3
votes
1answer
306 views

Installing wp3.2.1 on IIS; getting empty sessions

i have to install wordpress 3.2.1 on IIS 5.0 (yeah, i know...) here. Brand new default wordpress installation, no plugins ore previous versions installed. So, i downloaded the 3.2.1.zip and the ...
3
votes
1answer
22 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
3
votes
1answer
147 views

Search widget breaks when using multiple loops?

I have created wordpress template that uses two loops via WP_Query object. Everything works fine except Search widget. I've been pulling my hairs out for three days now Googling like a madman,but ...
3
votes
1answer
576 views

Creating nested forum loops in bbPress

I'm creating a customised forums front page for bbPress, by listing forums in a different way to the bbPress default. Essentially what I'm trying to do is replace the use of bbp_list_forums() with a ...
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
5answers
1k views

Get date of last update outside of loop

I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using get_the_time() but there doesn't seem to be a "loopless" ...
2
votes
1answer
1k views

Is it necessary to reset the query after using get_posts()?

Is it necessary to reset the query after using get_posts() ? I have been looking at this page and I don't see any reference to get_posts() ... I can't make it out for sure from this page either. I ...
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){ ...
2
votes
2answers
3k views

Using a custom WP_Query with get_template_part loop

I have a query for a custom post type: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $books = new WP_Query(array( 'post_type' => 'wiki', 'posts_per_page' => ...
2
votes
2answers
536 views

Knowing the total number of posts before to get into the loop

Is there a way to know the total number of posts before the loop starts? I'm thinking in use two loops. The first will do the counting, while the second one will handle the content. However, I don't ...
2
votes
4answers
2k views

Order posts by custom field and if custom field is empty return remaining posts

I have an archive page ordered by a numeric value in a custom field. This returns the ordered posts correctly, but does not display posts that don't have a custom field. $paged = ...
2
votes
3answers
4k views

How to use a custom post type as front page?

I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type archive with the following code ...
2
votes
1answer
3k 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)?
2
votes
1answer
10k views

wp_pagenavi() with custom wp_query()?

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

Query for posts in 2 taxonomies

I am currently using the following code to display a list with links to posts in a specific CPT and taxonomy: <?php $custom_terms = get_terms('videoscategory'); foreach(array($custom_terms as ...
2
votes
2answers
73 views

Why does this loop only work on the homepage?

I've been trying to figure this out all day now. Consider the following code below: <div class="slider"> <div class="slides"><?php wp_reset_query(); ...
2
votes
1answer
1k views

Pagination with custom post types results in 404 issues

I've a very simple index.php: <div id="content"> <? get_template_part('content', get_post_format()) ?> </div> <div id="pagination"> <? previous_posts_link() ?> ...
2
votes
1answer
571 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 ...
2
votes
1answer
344 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 ...
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
2answers
845 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 ...
2
votes
2answers
2k views

Ajax loop refresh on click

I display a random post loop on a page. I'd like to put a "refresh" link to refresh the content of the loop via ajax. Is this possible? This is my loop if it helps: <ul ...
2
votes
1answer
86 views

Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere

I'm trying to create a related posts WP_Query. So far, I've to created a custom WP_Query that queries all posts that match an array of tags. However, I'm trying to create a simple if statement: if ...
2
votes
1answer
272 views

Can't show comments count per post outside loop

How can I show the amount of a comment per post outside the loop? I tried this in a function already: ' . get_comments_number . ' , but that outputted the text "array" on the screen... What do I have ...
2
votes
2answers
278 views

How to show a category post to a specific registered user

I'm working a private blog and I'd like to know if this can be done with any other plugin or any other way: Lets say we have 3 categories: CA, CB and CC, and 3 users, UA, UB and UC, all of them can ...
2
votes
2answers
286 views

Splitting the main query in multiple loops with query_posts and/or pre_get_posts?

I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.). I'm ...
2
votes
1answer
2k views

Insert image or ad script after 3 posts using the loop

There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above. This is the ...
2
votes
2answers
1k views

How do you split multiple-column loop on category archive page?

I am creating a custom page template with multiple loop like this http://demos.gabfirethemes.com/advanced/category/football/ You can see there are posts split up into multiple columns: One featured ...
2
votes
1answer
403 views

Multiple Queries and Excluding Repeating Posts?

I'm trying to work out how to exclude posts used in the first four custom queries in the last typical query.. haven't been able to find anything that will explain how to do this clearly. My First ...
2
votes
1answer
554 views

add_filter() doesn't work in loop

I'm trying to order the posts in the home page by modified date, and I put this code in the functions.php of my active child theme: function orderby_last_modified() { return 'post_modified DESC'; } ...