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
vote
2answers
203 views

Combining the_excerpt with the_content

I have some html: <div class="container"> <p class="accent">The first paragraph...</p> <p>The rest of the article...</p> </div> I'd like to put "the_excerpt" in ...
1
vote
1answer
499 views

Facebook “like” open graph meta in header.php

I would like to add open graph meta tags to my header.php, but can someone explain how this works if header.php comes before my loop with the relevant information?? <meta property="og:title" ...
1
vote
2answers
182 views

Different style for most recent article

I'd like to make my most recent article display a large with a larger thumbnail and with more content, while the rest of the posts in the loop show a small thumbnail and only the title with no ...
1
vote
1answer
3k views

Dynamically excluding current page id

I'm attempting to create a "related posts" section on pages using query_posts. I'm wanting to use this simply because we want to show random posts from one category on one page, so a plugin would be ...
1
vote
3answers
2k views

Using new WP_Query in shortcode in a custom field causes the main post content to not display

I've got a custom post type of files I'm trying to list using a new WP_Query. It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field ...
1
vote
4answers
866 views

Using one WP_Query object within the loop of another WP_Query object

I'm creating two different WP_Query objects, one for each of two different post types I'm using. In creating my output, I'd like to loop through one of the objects, and at the same time loop through ...
1
vote
1answer
815 views

Post Format single-loop.php using get_template_part

I have set up to use post formats gallery and video in addition to the standard. I am editing the loop-single.php to give it different layouts for each post format, but I'm to include ...
1
vote
1answer
322 views

Custom loop with conditional statement to separate each terms

Let's say for example: I have a custom taxonomy called "fruit", which has 3 terms "apple", "orange", and "grape". So in order to get all the posts within all these three terms, I would : $args = ...
1
vote
2answers
1k views

How to determine if an admin is logged in outside the loop

I need to be able to tell if an admin is logged in ouside of the loop. This is needed for some php files that are part of a WP site but do not use require( '../wp-load.php ); What I need to do is ...
1
vote
2answers
164 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
vote
1answer
3k 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
vote
1answer
146 views

Varying Search Result Pages

I have two different kinds of search results on my site and I'd like to change the look of the search result page entirely. I've played around with the search form a bit but I'm unsure how to force it ...
1
vote
1answer
686 views

Custom excerpt function re-factoring

This may be more of a php best practices question, but here goes... I am using a custom excerpt trim function: function new_wp_trim_excerpt($text) { // Fakes an excerpt if needed global $post; ...
1
vote
1answer
274 views

Differentiate between posts and pages in search results

How can one differentiate between posts and pages in search results? What I need to do is show a the_time div for posts but not show it for pages, as it's irrelevant. With a function? <?php if ...
1
vote
2answers
354 views

Why would in_category only return one post in a specific category?

So... what I'm trying to do is simple - get the post content for all posts, but only in a given category. Simple - filter the loop using in_category. So I did this (this is actually a stripped version ...
1
vote
2answers
1k views

Adding 'current_post_item' class to current post in the loop

I'm using a loop in the sidebar of my site to show all the posts that are in that category. Now I'd like to include a 'current_post' class to the current post that is being displayed to style that ...
1
vote
2answers
357 views

Multiple loops on the same page removing post tags

I am trying to use two loops on my page, one to get the current page's content and so on, and another to get all of the posts of a specific category. When I do that, all of the tags for the current ...
1
vote
1answer
1k views

Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?

query_posts( array ( 'post__in' => array( 5, 76, 21, 56, 3 ) ) ); I'd like to query the Loop using post__in and a set Wordpress IDs. I'd then like to run through the Loop in the exact order of ...
1
vote
1answer
2k views

Custom Post Type Loop within Shortcode

I'm really at loss as to why this isn't working: I am using a shortcode to display a query on a custom post type + taxonomy, this is the segment of it: // - arguments - $args = ...
1
vote
1answer
2k views

How to insert content from another Custom Post type into Post?

Say I have a custom post type called "Performers". This gets populated with different bands/performers. These posts have a featured image as well as custom fields (mp3 file, facebook link, myspace ...
1
vote
3answers
489 views

get the image of the post

Im running 'the loop' and I want to get the image of the post (in original size - not thumbnail), how do I do it? thank you.
1
vote
1answer
374 views

How can I show the post thumbnail from the most recent of a certain post type, in widget?

I'm using the excellent PHP Code Widget plugin, and want to create a widget that displays the post thumbnail (aka featured image) for the most recent 'project' post. Here's the code I have so far, but ...
1
vote
1answer
147 views

Loop - how to get previous/next post for first/last post?

I have a simple loop for a JS slider, I want to display previous and next posts titles on my slide, but I can't get previous post title on the first slide (because apparently first post have no ...
1
vote
2answers
542 views

Including all terms in wordpress tax_query

I'm a little bit confused, why I can't include all the terms in tax_query automatically? My code: 'tax_query' => array( array( 'taxonomy' => 'city', 'field' => 'slug', ...
1
vote
2answers
199 views

Display content from custom post type if match to main post category

I solved the problem of displaying from a custom post type in a post with this solution, however, I want to filter even more and only display the posts from custom post type that match the main post's ...
1
vote
1answer
83 views

First post of each category

I'm trying to create a simple loop, that gets the latest post of 3 selected categories. I've searched for something similar to learn from, but most are overly complex. At the moment, I have: ...
1
vote
1answer
24 views

How can I modify the loop from a plugin without wiping out other filters?

I am trying to modify the_loop output from a plugin. I've looked into pre_get_posts, which definitely works, but I need to filter the loop by a custom taxonomy. I can do this with ...
1
vote
1answer
79 views

Query custom post type in the loop

I have a custom post type running called services: // Services function services_cpt() { $labels = array( 'name' => _x( 'Services', 'post type general name' ), ...
1
vote
1answer
436 views

Show newly added posts since last user login time /date

I'm looking for a solution to create a custom loop which will only display the last added/ modified posts since the last user login to the site. It shouldn't be that complicated doesnt it ?
1
vote
1answer
555 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
108 views

echo current taxonomy id for this loop?

I have this query to get posts and show like this: Custom taxonomy 1 <div ID1> |-- post 1 |-- post 2 </div> Custom taxonomy 2 <div ID2> |-- post 3 |-- post 4 </div> ...
1
vote
1answer
184 views

IF statement in a do_shortcode

Is it possible to do a if statement in a do_shortcode? <?php echo do_shortcode("[table width='500'] " . if ( have_posts() ) : while ( have_posts() ) : ...
1
vote
1answer
70 views

Create a loop that gets pages with their template

I am trying to make a template that will be an html5/ vertical scrolling base. I have created an amount of page templates that each would represent a <section> on index.php which mainly all it ...
1
vote
1answer
470 views

How to display 7 most recent days of posts?

I would like to be able to display on my homepage a timeline of posts from 7 of the most recent days. For example, if today is January 1, 2013, I would like my blog feed to display something that ...
1
vote
1answer
410 views

Get titles of all posts with current tags except current post

I am trying to print out a bulleted list of all posts in the current posts category (i.e. "siblings") except for the current post itself. I have been able to get the tags of the current bost and ...
1
vote
1answer
143 views

How to adjust code to refresh a dropdown box with tags that are active on filtered category listing

I have multiple custom tags setup (ptags) and custom posttypes (products) and made it so i can filters posts by multiple tags in a category. Currently the code retrieves tags from posts relating to ...
1
vote
1answer
284 views

Count singular post views automatically

I'm trying to add some function to each loop called in the themes. What I'm doing is I add a function to count post view from here post views without plugin, to use the function I need to add this ...
1
vote
1answer
184 views

Loop after page content

I just upgraded to 3.4.2 from 2.9 (i know, i know, but if it ain't broke...) I have page templates that are (or at least were) set up to display the page content first, then start a loop of posts, ...
1
vote
2answers
595 views

Load comments per post on click with AJAX

I'm working on a theme that uses a slider to display blog posts. Beneath the slider is a pagination that displays like a timeline, with a date instead of a page number, calling the corresponding blog ...
1
vote
1answer
181 views

Add inline HTML to posts published within last 24hrs

Basically I'm looking to add this line of code to posts published within the last 24hrs: <span class="new">New!</span> When the post is over 24hrs old, remove the inline HTML element. ...
1
vote
1answer
290 views

using new WP_Query in save_post function alters $post

I'm trying to include a WP_Query in a save_post function for a custom post type. The query is used to check all the other posts for a custom field bh_shortcode to make sure the content of the field is ...
1
vote
1answer
206 views

Function to show only first instance of shortcode

I need to add a function to my theme to remove additional instances of a shortcode in a post. First off I wonder if i'm approaching this wrong, but I have a theme that is drastically reformats the ...
1
vote
1answer
122 views

the_excerpt not showing posts

I'm using the following code to show the single most recent post on my landing page: <?php if (have_posts()) : ?> <?php if (($wp_query->post_count) > 1) : ?> <?php while ...
1
vote
1answer
38 views

Displaying the last page of posts

I'm using a custom loop to display posts using pagination. My query shows 4 posts per page, and there are 4 pages, so 16 posts in total. Is it possible to load in the last page of posts first? So when ...
1
vote
1answer
893 views

Display category posts grouped by taxonomy

I'm working on a project where I use the default posts as "Products", default category as "Application" and a custom taxonomy called "Groups". I want to list "Products" by "Application" ...
1
vote
1answer
336 views

How does the ternary operator work in the wordpress loop post?

Okay so I kind of understand that ternary operators work like condition ? TRUE : FALSE However I'm looking a simple loop to get my posts that I have <?php if (have_posts()) : ...
1
vote
1answer
613 views

Merge two WordPress installations into one, and keep posts separated?

I have two Wordpress installations that I would like to make into one installation, but still keep the posts (and their meta-data) separated. Both installations currently share the same database. I ...
1
vote
1answer
1k views

wp alchemy multiple image uploader output images to template

I am using wp alchemy to add a custom metabox to my site with multiple image uploader option. This part is working fine, but I have no Idea how to go about outputting the image links to my template. I ...
1
vote
2answers
1k views

Single page site (Wordpress) including posts

I'm creating a single page site and obviously want to include the blog posts. I'm currently looping through the pages and using the_content() and the_title() to display them. However, the_content ...
1
vote
2answers
615 views

Pagination on 2nd loop

OK, I am creating a business listing site that is using a custom taxonomy for the listing "type". I need to display two loops on the taxonomy archive page, one for "sponsored" listings and one for ...