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)

2
votes
3answers
165 views

Exclude category from loop not working

I have this code in my index.php file. I have a different template for a static home page, this is the blog page. I'm trying to exclude all posts with the category "new" which is tag_id "13" <?php ...
2
votes
1answer
2k 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'); ...
2
votes
2answers
685 views

The correct way to call posts with ajax

I'm trying to write an image gallery plugin with jQuery. I'm using jQuerys $.post AJAX method to send and receive info from the relevant post page. Basically I'll be looping through the attachments ...
2
votes
2answers
338 views

Wordpress Loop - Style rows of posts differently

I am trying to adapt the Wordpress loop to style posts differently in rows that get infinitely smaller until all posts are displayed The concept here is to display posts in rows first row 1 post ...
2
votes
1answer
369 views

WP_Query not looking at child category

Hi all I have a loop that shows a post on a single page and puts the first category name in the variable $cat: $cat = $category[0]->cat_name;?> Now after the post I have a link to show ...
2
votes
1answer
555 views

Generating dynamic Tabs with multiple query post loop

I am trying to generate a dynamic tab based navigating with query post my code is like this <div class="tabbable"> <ul class="nav nav-tabs"> <?php ...
2
votes
2answers
358 views

How do I override part of the main loop in my child theme?

I have a child theme based on the twenty ten theme which I am happy with except for one thing. My gallery posts (I am a photographer so the goal of my blog is pictures) do not show any images from ...
2
votes
2answers
460 views

How to order posts tag by tag?

I want to order my posts by tags with only one WP_Query() In my WP_Query I would like to display 2 posts with tags portrait 2 posts with tags paysage 2 posts with tags portrait 2 posts with tags ...
2
votes
3answers
693 views

Wordpress query by category, sorted by custom field

I have three custom fields set for each of the posts in the events category — year, month, and day. I am already querying for the events category, and now I'd like to sort the posts by the custom ...
2
votes
2answers
369 views

How to order results by date and meta key?

I'm using wp-postratings to rate posts which stores the rating as a custom meta value ratings_score. It gives you the option to use r_sortby to order the loop by highest rated but I want to give it a ...
2
votes
2answers
403 views

How WordPress converts URL to $query_string

My home.php shows a list of (N) posts and << Previous & Next >> links. When clicked, I want to fetch previous/next list of (N) posts using Ajax. This is: I do NOT want to load the entire ...
2
votes
1answer
521 views

Editing the loop for Author pages

I was wondering if anyone can help me out. I am looking to remove the_content part of the loop on my author pages only. So basically, I just want a list of the author posts with only the title and ...
2
votes
1answer
856 views

the_excerpt(), get_the_excerpt() and the_content() all killing “the Loop”

Before I call the_excerpt(), the_permalink() displays the correct thing. Afterwards, it does not... <?php global $query_string; //strip out the ...
2
votes
2answers
621 views

How to list custom post types?

Here's what I'd like to do: a) Create a custom post type and write panel for a menu item called "My Stuff." b) "My Stuff" will behave like a category -- but the content will not appear in the main ...
2
votes
1answer
678 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 ...
2
votes
1answer
473 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 ...
2
votes
1answer
103 views

Impossible to get Attachments Outside Wordpress?

My page (outside the wordpress install) begins something like this: global $wpdb, $wp_query; define('WP_USE_THEMES', false); include_once 'word/wp-blog-header.php'; $args = array( ...
2
votes
1answer
714 views

get_template_part from plugin

This is default get_template_part function inside WordPress: function get_template_part( $slug, $name = null ) { do_action( "get_template_part_{$slug}", $slug, $name ); $templates = array(); ...
2
votes
2answers
206 views

single page site with subpages

i want to make a single page site which has subpages with following structure about us team -member1 -member2 contact and i want the output to be like <div class="about-us"> team content ...
2
votes
0answers
2k views

Display products for a category, sorted by post_excerpt

I'd like to display a list of products for a certain category, sorted by the post_excerpt. The original code I used was this: $args = array( 'tax_query' => array( array( ...
2
votes
1answer
205 views

Help Structuring Query for Archive Pages

I'm building a site with several different post types (blog posts, products, informational articles, etc.). On archive type pages (search results, tag pages, etc.), I want to display content from the ...
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 ...
1
vote
5answers
1k views

is_home, and is_front_page conditional problem

I have this snippet in a "portfolio-loop.php" file. I'm using get_template_part to display the loop on the front page and on other pages. I have this within the loop: <?php if( !is_home() || ...
1
vote
2answers
110 views

Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?

I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. I have already tried running the second query via another ...
1
vote
6answers
6k views

How to get Author ID outside the loop

I can't get the post author ID outside the loop to make the get_the_author_meta work. So far I've tried different approaches: 1. $author_id=$post->post_author; 2. global $post; ...
1
vote
3answers
5k views

Override the default number of posts to show for a single loop?

Is is possible to override the set # of blog posts to show per page (as defined under Reading Settings in the WordPress admin)? I want to make it so a custom loop that I am using will show an ...
1
vote
1answer
420 views

Ajax loop in sidebar to load post titles/categories

I have a sidebar that displays the 20 latest posts, what I'd really like to do is Ajaxify that loop so there's a load more button at the bottom. The problem is, it's a fairly complicated loop and ...
1
vote
2answers
2k 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 ...
1
vote
4answers
1k views

Loop through all tags & output posts in alphabetical list

I have a bunch of posts that each have multiple tags, and I'm trying to find a way to output all of them on a single page, organized under an alphabetical listing of their respective tags. E.g. if ...
1
vote
1answer
846 views

Adding Pagination on a Custom Author Page

i have created a custom author's page that list the title of their posts. but the problem is i can't get the pagination to work if it's beyond the set post per page value. i have used get_posts() to ...
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 ...
1
vote
1answer
2k views

Formating the display of a post's date, outside the Loop

I'm using this function to be able to retrieve several data, from outside the Loop: function get_post_data($postId) { global $wpdb; return $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ...
1
vote
2answers
172 views

Output 2 items within the Loop

I have a query that loops through <li>'s and displays the number of <li>'s I have. Is there a way I can make the loop pull 2 <li>'s at a time rather than one? // 5 list items ...
1
vote
2answers
274 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 ...
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 ...
1
vote
3answers
427 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 ...
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
2answers
277 views

How do I display the function the_content in this loop?

I have this loop in my wordpress site which displays the latest posts with their titles, I want to display the post content after the title. I normally retrieve it with the function get_the_content ...
1
vote
3answers
60 views

Some doubts about how to show posts in a custom theme?

I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage: <?php if ( have_posts() ) : // Start the ...
1
vote
1answer
76 views

Undefined WP_Query::has_posts()?

This must be wrong. I was testing something so I did: $queried_post = new WP_Query(array('posts_per_page' => 5, 'offset'=> 1, 'category' => 1)); var_dump($queried_post->has_posts()); ...
1
vote
1answer
51 views

Reverse chronology of post listing

I"m working on modifying a theme that is based on 2010. I want to make the posts on this blog display earliest to oldest, but I don't see how to do this in the theme: I understand I need to add . ...
1
vote
3answers
161 views

Force index.php have_posts() loop to exit if no sticky posts found

I'm currently using the code below to list sticky posts on my index.php. However, when no sticky posts are present, its loading the latest posts (up to the number specified in "settings > reading > ...
1
vote
1answer
669 views

Is there any need to use both wp_reset_postdata and wp_reset_query together?

Is there any need to use both wp_reset_postdata() and wp_reset_query() together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query : ...
1
vote
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 = ...
1
vote
2answers
853 views

get_template_part() - post-meta not working?

Maybe I simply do not understand what get_template_part() is doing … I have a file called event-list.php that should work as template for other pages and files so all my events (a custom post type) ...
1
vote
1answer
717 views

Exclude custom taxonomy tag from loop

I have the following code at the beginning of a loop: <?php query_posts('showposts=3&cat=84'); ?> <?php $posts = get_posts('category=84&numberposts=3&offset=0'); foreach ($posts ...
1
vote
2answers
103 views

Help with Changing loop.php?

I'm trying to edit the loop so if its on category ID 60 it displays "Photos" instead of "Blog".. how do I do this? blog <?php ...
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 ...
1
vote
1answer
12k 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() == ...
1
vote
2answers
3k 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 ...