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)

-1
votes
1answer
169 views

new line after the_content

Trying to properly indent a theme I wondered if it would be possible to create a new line "\n" directly after <?php the_content(__('Continue reading <span class="meta-nav">&rarr;</span&...
0
votes
1answer
92 views

Use Author Ids or Names to echo different output inside loop

Is there a way to use the author ids (or names) to echo different output for different authors (in this case author id 7 and author admin? I tried the following but it didn't work. ?php if (...
0
votes
2answers
591 views

Please help me to win the battle with 2 column loop by category

I need help with this code. How can I change the code so that the posts from one category to be arranged like the this scheme. scheme picture <?php query_posts('cat=3&amp;...
0
votes
1answer
444 views

If/Else child list for Custom Post Type single template within loop?

I'm trying to add a feature to my 'Services' custom post type single template that displays one thing if the post type has one or more child post types and another thing if it doesn't. So far I've ...
0
votes
1answer
624 views

Using PHP Increment and Conditional Statement to Alternate Loop Background

I'm trying to alternate the background on a theme page that is displaying a custom loop: $args = array( 'post-type' => 'portfolio', 'posts_per_page' => 10 ); $loop = new ...
1
vote
1answer
784 views

How to hide all child pages with post_query?

i have a page template as start page(home.php). i use a 2 columns grid to display all pages on that home.php with title and excerpt. unfortunately also my child pages are shown and i can't figure out ...
0
votes
2answers
1k views

Page not found yet the posts are listed?

OK, seriously. I have a really modified index.php. The result: after the second paginated page, the page returns Not found and 404, while the posts are shown already. Can anybody tell me, what it ...
0
votes
1answer
128 views

Broken pagination, need help figuring out why!

I just tried slapping together a poor-man's "featured post" section with this exact code out of my index.php: <div id="post-wrapper"> <?php if (is_home() && !is_paged()) : ?> ...
0
votes
2answers
603 views

Simple foreach loop help needed in wordpress “the loop”

I need a foreach loop inside "the loop" This is my current code (index.php) : <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div><a href="<?php the_permalink(); ?...
0
votes
2answers
402 views

wordpress showing all posts instead of date range

When going to http://craigmdennis.com/articles/ Wordpress uses the index.php template. When you go to http://craigmdennis.com/2010/05/ Wordpress uses the same template (markup below) but shows the ...
0
votes
1answer
59 views

Wrapping x posts in html without leaving empty html

So I'm trying to spit out unlimited numbers of posts for this wp_query, 6 at a time, each one being wrapped in <dd> so that it functions with my jQuery slider. The problem is, if I have exactly ...
0
votes
1answer
139 views

An action that runs after each post in the loop on index/archive page?

Is there an Action/a Filter that runs just after each post/post excerpt is displayed on these 2 pages? I use the_content and get_the_excerpt currently, but the_content causes a conflict with some ...
0
votes
1answer
86 views

Enabling users to control custom loop's query

Let's say we started a custom loop: <?php $custom_posts = new WP_Query(); ?> <?php $custom_posts->query('post_type=post&category=Uncategorized&orderby=epo_custom'); ?> <?php ...
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
700 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
702 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'] . '/wp-load.php')...
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
483 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: $args=...
0
votes
1answer
946 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
532 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
88 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
136 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
458 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
289 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
682 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
761 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 = (get_query_var('...
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
575 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
888 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
793 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
730 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?