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
2answers
4k 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 ...
0
votes
1answer
158 views

rewrite_rules problem

I am using scheduled posts as a event program, by making a loop pick up future posts. Every now and again, the production site starts to show 404's for the single event pages, and to fix it I have ...
0
votes
1answer
337 views

Too many nested wp_query loops in this hypothetical query?

I'm attempting something more complex than I've ever done before with WordPress, so please forgive me if this question doesn't make sense. I have a Books archive page and want it to display excerpts ...
0
votes
1answer
131 views

How to end this loop properly?

I´m using several similar loops to loop in content from different categories into different containers. If there are no posts in category X then it shouldnt open any container at all. Same with all ...
0
votes
1answer
786 views

Redirecting posts in Wordpress to a specific page

I created a page so that it would appear in my navigation menu. This page would however be my posts page (i.e. all posts would go here) and would also be my front page. I am unable to find anything ...
0
votes
1answer
334 views

Help with add_filter('the_content', 'some_function') and multiple matches

I have a site where a user can insert slideshows into a post by entering the shortcode in the content box. He can also add videos by adding the video code in the same box. I need to separate these two ...
3
votes
3answers
8k views

get custom post type by tag

Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop. <aside class="supporting_images"> ...
1
vote
2answers
5k views

WP_Query to get posts in a specific category and post format

I've been trying to utilize either WP_Query or get_posts to pull out the most recent post that's both in a specific category and of a specific post format. <?php $singargs = array( 'numberposts' ...
0
votes
1answer
1k views

Using jQuery toggle() in WordPress post to show/hide Tweet button?

What is the appropriate way to use jQuery toggle() function in a WordPress post to show/hide a Twitter "Tweet" button? The problem I am encountering is when I put the code in my content-post.php, the ...
0
votes
1answer
637 views

Fix custom query pagination without changing site-wide posts-per-page settings

Many people report problems with pagination of custom queries or custom post type archives: url/page/2 produces a 404 even though all the setup is correct. Many end up figuring out that this is ...
9
votes
1answer
29k views

Counting the posts of a custom Wordpress loop (WP_Query)?

I tried tplacing this: <?php $count = count($custom_posts); ?> <h2><?php echo $count; ?></h2> at the end of the loop: <?php if ( bbp_get_forum_title() == ...
0
votes
1answer
473 views

Script that gets the first tag of post and query all other posts with the same tag

The script gets the first tag of a post and retrieves in a wordpress loop all other posts with the same tag. I can't seem to get it working:( Any ideeas? $posttags = get_the_tags(); $count=0; if ...
0
votes
1answer
4k views

Show all posts in category

I am trying to show all posts in each category. I've been searching around and it seems I need to have either the category slug or term_id to do so, like the code below. <?php ...
0
votes
1answer
495 views

Pagination problem with multiple loops on the same page

I'm using 4 custom loops to display 3 posts on each one and every loop has its own pagination which works fine once the page loads up, the problem is that when I click on the 2nd page of the first ...
0
votes
1answer
220 views

The_content display a different content from a previous loop

I have custom template for my homepage. If i just put the_content(); to this template, nothing else, then it will display my text i entered in my admin panel in the editor. But if i have a different ...
12
votes
6answers
33k views

Get excerpt using get_the_excerpt outside a loop

I have a code that call get_the_title() and it works, but get_the_excerpt() return empty. How can i make it work? This code is inside a plugin called "WP Facebook Open Graph protocol". Here's the ...
0
votes
1answer
639 views

Getting two wp_link_pages output

http://i.stack.imgur.com/Yr35p.jpg As you can see in the picture above. I got two links for each page. I'm using <div class="pagelink"><?php wp_link_pages('pagelink=Source %'); ...
0
votes
1answer
598 views

WP_Query not returning correct result with meta_query parameter

I've got the following loop on my index.php template: <div id="new_on"> <?php $args = array( 'meta_query' => array( ...
0
votes
1answer
294 views

Get current taxonomy and display query accordingly

Okay i'm having a bit of a catogorisation/taxonomy/filtering problem here and am at loss on how to solve this. I hope someone could help me on the way a bit. Say I've got a blog about food, with a ...
1
vote
2answers
4k views

Custom loops, sticky posts, and pagination nightmare

I've tried everything. I've looked at every. single. question. here, on StackOverflow, the WP help forum, googled 10 pages deep and literally tried EVERY combination of code I could find, for the ...
1
vote
1answer
58 views

I've been out of the loop since 2.8. What did I miss?

I haven't done any serious WP development since version 2.8, although I fiddled a bit with version 3.0. Short of reading the release notes on each version, what are the major things to take note of ...
1
vote
2answers
852 views

Why do next pages load the same content rather then older articles?

For some reason, the 'previous posts' and 'next posts' on the homepage do not load previous posts, but rather the same posts that were on the main page. Why is that? I don't even know where to start ...
1
vote
2answers
181 views

Finding posts containing matching array elements in a meta field usign WP_Query

I have a metafield, that contains a series of options and writes the results to an array in a single meta field: array([0]=>'First', [1]=>'Second', [2]=>'Third', ); I find ...
-1
votes
1answer
369 views

jQuery cycle and WordPress: Captions, buttons, oh my

I'm attempting to use jQuery cycle to create a rotator on my blog (which will be used going forward on all other blogs) like the following: http://www.pbs.org/teachers <div id="feature-well"> ...
0
votes
3answers
2k views

a-z list, categories and sub categories in loop

I'd like to list my categories in a loop from a-z, the code i currently have just keeps repeating over and over im not sure what the problem is but the format should look something like. Parent ...
3
votes
1answer
410 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, ...
0
votes
1answer
678 views

Add custom post type to query

$saved = $wp_query; query_posts(array('tag__in' => $tag_array, 'showposts' => $args['posts_per_page'])); I need this to query standard posts and a custom post type called "property" I can't ...
1
vote
1answer
151 views

Help with Wordpress Query

I'm sort of a noob when it comes to Wordpess; I've only recently started building themes and I've run into a wall. I'm trying to feature 3 different articles at the top of my site using wpquery and ...
7
votes
2answers
3k views

How to check if I'm on the last page of posts?

I want to display some text on the last page that isn't displayed on the other pages. For example, on category pages: url.com/category/categoryname/page/6 or last page of all posts listed on the ...
0
votes
1answer
355 views

Can I access a post meta field before the loop?

If I call the following function (on a page template, e.g. page-home.php) before the loop, nothing is returned. If I call it during or after the loop, the expected values are returned. Is there a way ...
0
votes
1answer
687 views

Problem in replacing the_content with the_excerpt()

I want to add read more to a blog. For that I need to replace the function the_content(). I found it in the loop file and replaced it with the_excerpt() but still posts are being shown of full length. ...
0
votes
1answer
483 views

Show recent posts starting at a specific number archive

Is there an argument to define how many posts ago will be displayed in "recent" posts. Could I add something to this and define a specific number of posts ago to start the loop? $args = array( ...
1
vote
1answer
742 views

Filtering post-formats from the loop using new WP-Query();

Hi i am currently building upon a theme that i have build previously for my blog. The following code is to point to the latest post (the featured post). As this will have a different styling than all ...
0
votes
1answer
1k views

split wordpress loop into columns of categories and associated posts

Here is what I need to do with 5 columns on the "archive" page: I can already loop through the categories and posts in a loop to display them quite nicely, I just cant figure out how to split it into ...
1
vote
1answer
423 views

How to pass the current content of $wp_query to a new page?

I am developing a Wordpress theme that uses a lot of AJAX. It is composed of two main pages: the index, which displays a list of posts, and a viewer (similar to single.php). When a post is clicked in ...
1
vote
1answer
4k views

Refine search results using WP_Query

I am trying to modify (refine?) Worpress search results by using WP_Query, just as it's explained in the Codex. The snippet featured in that article is on the top of the Search Template PHP file, and ...
-1
votes
1answer
1k views

get_page() unlike Loop returns the post content without html tags. How can I fix this?

get_page() unlike Loop returns the post content without html tags. I need tags. How can I fix this? I don't want to change wysiwyg editor, here is the bad solution ...
1
vote
2answers
8k views

In a foreach loop, how do I target the last item in the loop?

I have the following code to do a foreach loop, I want to target the last item in the loop (e.g if it's looped over 3 events I want to target the 3rd event) to do something slightly different with the ...
0
votes
1answer
2k views

How to make the 'request' filter work?

I'm trying to get a Page to display a custom query using the snippet posted here. The following is in my functions.php: function alter_the_query($request) { $dummy_query = new WP_Query(); // ...
0
votes
2answers
172 views

Pagination Not Working When Modifying Loop Based on Post Category

I have added query_posts() to my index.php file to modify the loop on the posts page: query_posts( 'cat=-4,-7' ); get_template_part( 'loop', 'index' ); This works correctly, but when I click on ...
1
vote
1answer
399 views

How to make a second query offset -2 from current post

I would like a second WP_Query on a custom post type's single page to return 5 posts, starting with two before the current post, so that I get this: The-one-before-the-previous post Previous post ...
2
votes
1answer
274 views

Paging on a future post loop?

I am trying to get paging to work on my future post loop, but to no avail. I am getting no links, when I expect them at the bottom, for pagination despite there being several valid posts in the ...
1
vote
2answers
996 views

Easiest way to show total number of subpages

I am making a portfolio site where each portfolio entry is a subpage of "Work". In my template, I am trying to say something like: worked on 15 projects and counting, where 15 is the total number of ...
0
votes
1answer
4k views

Custom Post Type Category Link

I have a loop of posts for a custom post type I built. How can i call the link of the category/taxonomy for each post? Thanks
0
votes
2answers
2k views

How to change a custom query into a standard loop?

I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query while ( $the_query->have_posts() ) : ...
0
votes
1answer
99 views

problem with the loop

Hello I am working with my own template, and also using the post-to-post plugin, I am doing the following, <ul> <?php global $post; global ...
0
votes
1answer
430 views

creating a foreign key like relationship with custom post types

I am currently building a website, that is heavily reliant on custom post types, 2 of my custom post types are "Clients" and "Case Studies", now what I am wanting is a way to create a dropdown in the ...
0
votes
1answer
871 views

Show the categories the current post has

I have a custom post type; posts of this type can have either one or two categories associated with them. I need to display the names of the categories that are associated with each of these custom ...
0
votes
1answer
340 views

Ajax request with jQuery without WP_ajax

I try to made a website in full ajax (a html5 website). I use jquery and innerShiv (for ie). For exemple I want to load all the content of the "section" tag of a page. When I use that script, it ...
0
votes
1answer
108 views

loop on page makes shortcode fail

I have this typical WordPress page (page.php): <?php the_post(); ?> <div id="rightcol"> <div <?php post_class(); ?>> <?php the_content(); ?> </div> All works ...