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
1answer
689 views

Creating nested forum loops in bbPress [closed]

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
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
235 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
7k 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
4answers
4k views

Exclude the category from the WordPress loop

I have this code for the loop, and I need to exclude a category 4 from this loop. Any suggestions on how to achieve this? Code that starts the loop <?php if(have_posts()): ?> <ol ...
1
vote
5answers
3k 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
14k views

Get post count of current loop when using multiple queries on one page

I'm trying to get a count of the current posts inside of a loop. I'm using multiple loops on one page in my theme. So far I have: $my_post_count = $wp_query->post_count; But when I print ...
1
vote
2answers
140 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
3answers
6k 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
625 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
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
47 views

All posts are still shown when adding category argument to query

I've got the following code in my team-type.php file which I'm using to create a custom taxonomy for a member information: function create_team_taxonomies() { $labels = array( 'name' ...
1
vote
2answers
396 views

Showing current subcategory

I have problem. <?php query_posts('category_name=events&posts_per_page=2&offset=1'); ?> <?php while (have_posts()) : the_post(); ?> <div> <?php $children = ...
1
vote
4answers
2k 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
1k 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
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
312 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
99 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 ...
1
vote
2answers
201 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
9k views

How to get posts published between a date and today?

Is it a way to get posts published between a date and today with query_posts() ? Example : All posts published since 2012-04-01 Thanks EDIT : How to add the filter date on this Query Posts ? ...
1
vote
1answer
5k 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
630 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
3answers
2k views

Check if post belongs to any category

In my homepage loop, I have something that will show which category the post is in. It will say something like "Posted 4 hours ago in Sports by ...". However, when there is no category set, it will ...
1
vote
2answers
288 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
101 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
201 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
1k views

How can i display the content in plaintext

i want to display my excerpt in plaintext. How can i do this? This is my Snippet where i display the content: <?php the_content(__( 'Weiterlesen &rsaquo;','okay')); ?> How i change the ...
1
vote
1answer
101 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
256 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
764 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
2answers
987 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
835 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
104 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
2k 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
2answers
5k 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 ...
1
vote
2answers
816 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
1k views

category__not_in — anyway to use category name instead of id?

I would like to exclude categories from the loop using the "name" instead of the "id", since the ID can change when using new databases. The name however will always be the same. Is this possible?
1
vote
1answer
32 views

Creating Accordians in Wordpress Theme

I am creating a wordpress theme in which there is a section "HUMOUR". In this section i've created accordians, in which the 1st accordian is in class="active" and rest don't. for e.g <dl> ...
1
vote
3answers
30 views

the_content() seems to block my ACF-code

I have this simple code, but can't get the_content and the ACF-code to work together. If I include the_content() it blocks out the ACF-code, but if I remove the_content() the ACF-code works fine. I ...
1
vote
1answer
151 views

Loop starts from the beginning with second while loop on author.php

I am using the same template for author.php and home/blog.php. I have a loop split into 3 parts. <?php if(have_posts()): the_post; //do a thing endif: $i = 0; while(have_posts()): the_post(); ...
1
vote
2answers
103 views

Guidance with The Loop for CMS

Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 ...
1
vote
2answers
261 views

What are the disadvantages of using global variable?

I am a newbie at WordPress. In my "recent posts" shortcode, I used global $post variable, because the_title() function was giving me page's title, not post's title. I am not exactly sure, but I ...
1
vote
1answer
77 views

if/else on custom query gives 200 OK when condition not met?

What? I am modifying my theme to show comments of a post on a separate page. How? Mostly based on this answer but with improved checks and code. So this is what my page-comments.php (kinda) looks ...
1
vote
1answer
603 views

Operations with custom fields values in a loop

I have a foreach for displaying all the post in one taxonomy filter by terms. I have a custom field for display a numeric value. What I need, is to make two math operation with all the values of that ...
1
vote
2answers
513 views

Store loop into array

I am using folowing code to store posts ids into array: <?php $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => ...
1
vote
2answers
10k views

Woocommerce custom loop to show all the products

I'm currently working on an e-commerce website and I met an problem. My client want a page e-boutique with all the product categories displayed, followed by 3 promoted products and a button "show ...
1
vote
1answer
376 views

Custom search form to display users only

I'm trying to build a custom search form for one of my pages. I need the search form to be able to search for users. Not only will it need to search for users, but by first name, last name etc.. ...
1
vote
2answers
51 views

2 Loops, Only Displaying 1 Loop in Both Loops

I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either Movie Trailer or ...
1
vote
2answers
1k views

the_title() shows title of the first post instead of the page title?

I'm occasionally facing this problem and not sure what causes it, any ideas? <?php get_header(); ?> <div class="content" role="main"> <h1><?php the_title(); ...