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)

0
votes
1answer
2k views

get_the_title and get_permalink outside of the Loop

I'm trying to list the parent to a page in the sidebar. I can get the parent-page ID. I can get it to print with a print_r function, but no matter what I try I can't get get_permalink and ...
1
vote
1answer
41 views

replacing the_autor or make callback

I'm looking a way tho change the the_author(); function in the loop, I have post meta data with the name of the user who posted. I need to do this: If the user is registered, show the_author();, ...
-1
votes
2answers
2k views

Custom post type and have_posts() return empty result

I'm very confused regarding the have_posts(). It returns an empty result even though I have one post that match the query. The below code is used in a widget which should display exactly one post, if ...
1
vote
2answers
1k views

Very Slow Page - How to Optimize # of Queries?

EDIT 12/19/2011 Thank you again Ijaas. Everything is working except for the order of the days. It is ordering the groups of days by the publish order. If an older post has a newer date in its ...
0
votes
1answer
2k views

Display metabox title for custom fields with values

I'm using multiple metabox panels in my write posts. IN my functions I'm registering multiple metaboxes: $prefix = 'dbt_'; $meta_boxes = array(); $meta_boxes[] = array( 'id' => ...
0
votes
1answer
698 views

Magazine style frontpage with multiple categories/loops and no duplicate posts

I am migrating a static magazine site to wordpress. I would like to have a frontpage displaying multiple categories with a few posts in each, e.g "politics", "environment", "health" and "technology". ...
0
votes
1answer
694 views

How to sort posts by the average of comment meta values

Here's the situation- I've customized the comment submission whereby users can provide a rating, and this gets stored as a meta value in the commentmeta table. I can query to return the average ...
0
votes
1answer
1k views

Custom Post Type Query W/Category Dropdown

I'm having a bit of trouble getting a custom post type query working coming from two drop downs. Let me show you what I'm using: The Form: <?php require($_SERVER['DOCUMENT_ROOT'] . ...
0
votes
1answer
61 views

Custom fields in post later used in loop

How i can add custom fields to custom post templates, and later print them in The Loop? Better explanation: I want to have a custom field in "Add New" window, which will be added as some meta data to ...
0
votes
1answer
481 views

Retrieve IDs from custom field, count and display results differently according to count

The function below is inside a single post loop. I have an array of IDs in a custom field. Such IDs represent related posts. I'm using Advanced Custom Fields (ACV) plugin and I manage the custom ...
0
votes
1answer
3k views

When to use Wordpress loop or Foreach loop?

Under what circumstances would you, (should you?) use a foreach loop, instead of the wordpress loop. I have no real coding need, but I'm curious. What's good practice here? Should I: ...
0
votes
1answer
934 views

$wpdb->flush(); breaks the loop

I am using $wpdb->flush(); at the base of my page in an attempt to prevent the query executing multiple times due to caching however it seems that it isn't flushing the most recent query but the ...
0
votes
1answer
529 views

MySQL query performed 4 times inside loop

I have enabled custom php in my pages through the use of the exec-php plugin so I can run more complex pages than the standard WordPress page. I have had no problems with this plugin so far. I have ...
2
votes
1answer
87 views

Different Queries Return Same Results [closed]

EDIT: After fiddling with the loop a bit, it somehow corrected itself. At the end of the day the code remains the same, only now it's working. http://sct.io/tt95p4 - development site. Scroll down ...
1
vote
1answer
135 views

Rating system and changing the loop

Alright, so I want to see who can help me implement this idea I have. I just want one single Icon next to a post. If you click it, then you "Heart" it or "Love it". The post has a counter to see how ...
0
votes
1answer
1k views

Changing WordPress sort order for returned child pages

I have a custom WP_Query that looks like this: $this_page_id=$wp_query->post->ID; $images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id ) ); My ...
-1
votes
1answer
266 views

Custom Page Template and Category Exclusion

I have a blog (bernsteinbear.com) that uses the TwentyEleven theme. I'm trying to make a custom page template for the front page (a blog page) that gets all the posts except in the "Comic" category. I ...
0
votes
1answer
2k views

Group posts by date with a list

I want to set a group of posts grouped by date as a list. Below is what I would like to have: Day... <ul> <li><a href="#">Lorem ipsum</a></li> </ul> Previous ...
0
votes
1answer
455 views

Defining 'last' class on foreach blog posts

I'm using the following code to display the latest 3 blog posts on my front page but I need to add a last class to the 3rd post on the ID blog. <?php $args = array( 'numberposts' => 3 ); ...
4
votes
1answer
2k views

save_post + insert_post = infinite loop

I'm trying to automatically create a new post when a post containing a certain custom field is saved - hooking an insert_post function into save_post. This generates an infinite loop. I found some ...
0
votes
1answer
288 views

Open Graph in Index Loop

I have an index of posts where I'm wanting to insert a Facebook Like button for each post. Thus far, I've set all Open Graph data in the head for single posts. Any ideas on using the open graph data ...
0
votes
2answers
681 views

Post per page not working if no category specified

I'm going crazy... <?php query_posts(array('cat' => 3, 'posts_per_page' => 1)); ?> This shows 1 post (there is two in the category) >> OK <?php query_posts(array('posts_per_page' ...
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
1answer
1k views

Check if date of post is yesterday

In a loop, I want to display "Yesterday" if the date of the post(s) are dated from yesterday... So here it goes: <?php if( date('Yz') == get_the_time('Yz') ) { echo 'Today'; } ...
2
votes
3answers
1k views

Why am I getting an infinite loop with have_posts?

I have the following code, which causes an infinite loop for some reason. Can anybody explain what's going on please? Thanks! <?php $flagged_stores = new WP_Query( array ( 'post_type' => ...
0
votes
2answers
755 views

$post in wp_query?

How do I get the $post Variable in a WP_Query started loop? I have to get the excerpt, raw $post->post_content and further things. This is why I have to get Access to the Variable itself. How am I ...
0
votes
1answer
4k views

How to get posts using category slug in ClassiPress?

I'm using the ClassiPress theme as a base for a new theme. If you have worked with classipress, you should know that classipress handles its own category using the taxonomy ad_cat. That said, I have a ...
1
vote
2answers
492 views

List posts AND custom post type by category

I found this question asked elsewhere, but it was unanswered, so I'm asking myself. I have a custom post type (Features) that shares my Categories and Tags with my standard posts. I'm listing my ...
0
votes
1answer
3k views

facebook like, tweet and google+1 buttons inside the loop on home, archive and search pages and missing facebook like buttons

Is there a way to add social media buttons, especially facebook like, tweet and google+1 inside the loop for each post on home, search and archive pages without getting masses of script downloads? ...
0
votes
1answer
307 views

Custom Post Type, Pagination and 404s?

Head is getting melted with this pagination crap in WordPress! What am I doing wrong here… Test site http://www.clients.eirestudio.net/savvas/reviews/ Code <?php $paged = ...
0
votes
1answer
296 views

Catergory args causing loop not to show

this has taken up most of my afternoon, but i just cannot get it to work properly. The issue is when i try to add a catergory argument to my custom loop, whether it is an include or exclude. When i ...
0
votes
2answers
571 views

Is file_exists() compatible with timthumb.php? [closed]

I'm using the latest timthumb script to generate my post thumbnails and include them along with the excerpt. Though I only want the thumbnails to load if their files actually exist, otherwise I don't ...
0
votes
2answers
1k views

query_posts and sub pages?

I have a Page layout like this Parent Page - Sub page 1 -- sub sub 1 -- sub sub 2 -- sub sub 4 - Sub page 2 -- sub sub 1 -- sub sub 2 -- sub sub 4 I want to query every single child page, ...
0
votes
1answer
885 views

Add 2 values to post__not_in

How can I add to values to the post__not_in function? For example, I want to exclude $value1 and $value2 from a loop Any ideas? Thanks in advance
1
vote
1answer
788 views

Is it possible to have pagination with an offset loop?

I am developing a blog page that requires 3 different post styles (Ie; one full page width with featured image and content, one full page width without featured image and the rest are half page width) ...
0
votes
1answer
723 views

Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?

Ok, this may be a bit confusing but here goes... Im working with several custom queries on the same page throughout my site. Some queries are grabbing regular post data, others are fetching CPTs ...
1
vote
2answers
1k views

Get a list of commas separated categories inside a loop

I want to get the list of categories of a post inside the loop. Normally, I would use the_category(', '); But this does output a link, and I only want the category name. Any ideas?
0
votes
1answer
440 views

How can I increase the post count for custom post types only?

I have the page count set to the default 10 in my reading settings menu. However, I use my template archive.php file for all post types, including posts and books How can I change the loop so that ...
5
votes
6answers
19k 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 ...
0
votes
2answers
2k views

While loop inside another while loop

OK, so I've read like 20 different articles about using a while loop inside another while loop, but still can't get this to work, and I'm about to burst from frustration. My scenario: using the ...
0
votes
1answer
1k views

how to json_encode(); the Loop content so that the encoded array is [“0”:content, “1”:content]

<?php $dVC=array(); query_posts('meta_key=featuredt&posts_per_page=5'); if (have_posts()) : while (have_posts()) : the_post(); $dVC []= $post->post_content;?> <div ...
1
vote
1answer
252 views

Adding general page content to page templates

If I'm creating a page template, let's say for example one for a testimonials custom post type I've created, I think I have it figured out that if I do the following in page-testimonials.php: ...
0
votes
1answer
239 views

The Pagination doesn't work

i have made a new WordPress Theme and ive done .. but i have one problem. I can't get the pagination work. I use the "wp-paginate" plugin and i have put the folloing code on my index.php <?php ...
1
vote
1answer
1k views

Custom post type multiple loop by taxonomy term

I would like to create one loop that lists the custom posts for each taxonomy term: Term A: Item Item Item Term B: Item Item Item I would like this to be totally dynamic so if I add a new term it ...
0
votes
2answers
588 views

Add class to last 3 posts in loop

I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it ...
0
votes
1answer
131 views

use custom field value as post category in loop

I have a page template and at the bottom, I want a loop of posts based on a custom field value - store_name This is what I have: <?php global $wp_query; $paged = (get_query_var('paged')) ...
0
votes
1answer
586 views

WP Query get only 1 post (sticky, not sticky etc)

I'm using WP Query & want to only return 1 post in a category. Either the most recent sticky else the latest post. Is this possible? Thanks, George <?php $category1 = new ...
0
votes
2answers
955 views

How to make the first post in the loop be styled like a “new / featured” post?

I hope i can explain this right , what im trying to do is use the default word press loop to show all my posts etc.. but for the first post I would like it to be styled completely different depending ...
1
vote
1answer
189 views

Sidebar loop - Thematic Framework

I'm trying to add a sidebar loop to list 3 news post. I'm using thematic framework and since I don't find any hook to use I first write this function in functions.php function sideloop(){ ...
0
votes
1answer
737 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 ...