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
1answer
185 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
300 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
217 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
124 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
979 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
2answers
2k views

How do I get the attributes of a short code from a post?

I am trying to preview a NextGen gallery on my main page (and category pages) to show a single image from the gallery on the main page next to the text from the post that normally shows up. I have ...
1
vote
1answer
353 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
645 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
2answers
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
629 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 ...
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 ...
1
vote
2answers
2k views

wp_list_categories: get latest featured_image of category

I was thinking about a nicer way to display the categories in my sidebar. Instead of a plain list style, I'd like to have images / thumbnails show up as well. Currently I'm using the following: ...
1
vote
1answer
56 views

I've been out of the loop since 2.8. What did I miss?

I haven't done any serious WP development since version 2.8, although I fiddled a bit with version 3.0. Short of reading the release notes on each version, what are the major things to take note of ...
1
vote
1answer
150 views

Help with Wordpress Query

I'm sort of a noob when it comes to Wordpess; I've only recently started building themes and I've run into a wall. I'm trying to feature 3 different articles at the top of my site using wpquery and ...
1
vote
1answer
631 views

Filtering post-formats from the loop using new WP-Query();

Hi i am currently building upon a theme that i have build previously for my blog. The following code is to point to the latest post (the featured post). As this will have a different styling than all ...
1
vote
1answer
3k views

Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?

I have this custom loop: <?php // Display the top ones $args = array( 'post_type' => 'reply', 'post_parent' => $post->ID, 'r_sortby' => 'highest_rated', ...
1
vote
1answer
425 views

PHP loop that selects posts with a particular in-post option

Im trying to build a Featured post slider to show any post that i mark as a "featured" (with a in-post option) regardless the category or tag type... Im new to wordpress and although I understand a ...
1
vote
2answers
643 views

query_posts() ALWAYS displays something?

OK, I'm using posts_query() to display posts. The problem is, at least in my case, posts_query() always outputs something. For example: <?php $paged = (get_query_var('paged')) ? ...
1
vote
2answers
2k views

get_template_part and template file names

I have a custom post type that is going to use a loop in a couple different places and I wanted to make maintaining those loops easier. I remembered that get_template_part() is available and figured ...
1
vote
2answers
939 views

Breaking the loop?

WP loops are widely used to print lists of posts in Wordpress: <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'ff' => 'show_ff', 'orderby' => 'menu_order', 'order' => 'ASC' ...
1
vote
1answer
619 views

Can I create a loop with multiple post types and specify different $args for each post type?

I'd like to create a custom loop that includes all Post types: Post and Video. Then I'd like to specify to show all posts of the post type Video, but only show posts that are in the category ...
1
vote
2answers
316 views

How to track post number on the_loop

I have a need to customize some posts from the loop. Here's the deal: My site is set to 10 posts per page. On post #2,#5, #7 (on every page), I want to display specific background. What's the best ...
1
vote
1answer
19 views

Display custom post on home page based on a metabox selection

I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection ...
1
vote
1answer
27 views

Inserting custom data to the_post() during loop

I have some posts on my WordPress site, and let's say I want to add a random number for each post with $num as key and random() as value. Then I want to access them with something like: $post->num ...
1
vote
2answers
73 views

Transient not working for custom loops

I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of ...
1
vote
2answers
175 views

Single Page Wordpress Theme - Using page templates

Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress "pages". How I have initially setup ...
1
vote
2answers
99 views

Ways to have multiple front-page.php templates that can be swapped out?

I essentially want to create several different front-page.php templates with different loops and layouts and then present an option in the admin panel to select one template on one day and a different ...
1
vote
4answers
96 views

Create static front-page with 3-5 recent posts

I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the Underscore boilerplate. As I understands, the ...
1
vote
3answers
459 views

Previous and Next Post link doesn't work

In single.php I tried to add inside the loop the previous_post_link and next_post_link. But nothing is rendered when a view the source of the site. I added the previous_post_link inside an h4 tag to ...
1
vote
1answer
42 views

Modify main loop in taxonomy archive page

Is there a way that I can modify the main loop in a single taxonomy template, but leave it untouched in every other template? In this case, I have a custom post type called "Events" which in turn has ...
1
vote
1answer
220 views

Filtering posts by multiple taxonomies

I have a page on which I want to display all posts of a specific custom post type, let's call it "persons". I want to allow the user to filter all persons by multiple (!) taxonomies: age, city, ...
1
vote
2answers
57 views

Get_post_meta() won't return value

Ok guys... I'm sure this is going to be a really easy answer. I'm a complete noob at this. I have a custom field that is supposed to return a link. For some reason, it just redirects me back to my ...
1
vote
1answer
99 views

One custom loop with condition to check child posts

I have one loop of pages with 999 page ID as a parent (pages from this loop have also another child pages) $args = array( 'post_type' => 'page', 'post_parent' => 999, 'order' => 'ASC', ...
1
vote
1answer
226 views

Loop get_theme_mod

I've got a bunch of customizer settings set up Rather than calling individual get_theme_mod statements for each setting individually, is there a way to simplify it to loop thru them without having to ...
1
vote
1answer
34 views

How do I display the posts from a custom post type on a category.php page?

I have set up a category.php according to this wordpress hierarchy diagram. When I am on the page http://example.com/category/my-category I want to display all posts that are under my-category using ...
1
vote
1answer
855 views

display posts with same taxonomy term

I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called venues thus each post has a venue ...
1
vote
1answer
113 views

Dynamic Stylesheet loads but doesn't finish

I am creating a website for an architect with large images being a main feature of the site. Given the potential size of the images I wanted to have a way to create responsive image sizing (and of ...
1
vote
1answer
162 views

Alphabetical sorting of custom post type - one letter per page

Basically what I am looking for is a way to sort custom post type in alphabetical order and separate each letter, so you have one letter per page. See illustration. Hopefully there is a plugin or ...
1
vote
1answer
253 views

How do I restart my loop with get_next_post()?

I'm looking for a succinct method of making get_next_post() double back to the beginning once it hits the last post. Currently, it stops once it hits the final post. Here are a few lines of code from ...
1
vote
2answers
376 views

Loop custom taxonomy to get lists of cutom post types?

I have a custom post type 'products' and custom taxonomy of 'maker' that i have connected to that cpt 'products'. I have written this code : <?php $myproducts = new WP_Query(array('post_type' ...
1
vote
2answers
103 views

Grab the first paragraph of each post

I have some code that uses preg_match to grab the first paragraph, and then spit it out in the loop: function first_paragraph() { global $post, $posts; $first_para = ''; ob_start(); ...
1
vote
1answer
101 views

Move sticky posts down in main loop

Currently I am working for a site which runs on WordPress, and using twenty thirteen theme which already has a sticky post function built in and working reasonably well. But I do not like how a ...
1
vote
1answer
88 views

Normal pages as children of my Custom Post Type

This one is tricky, I've got Custom Post Type called "dictionary", users add "definitions" there which are automagically put into right categories (so for example if user adds "Apple" it's under "A"). ...
1
vote
1answer
61 views

How do I run through a Wordpress loop called from a filter function?

So I'm trying to populate an Advanced Custom Fields selectbox with a nice complicated array based off some post data. I've been trying to do this by doing a custom query and loop through the returned ...
1
vote
1answer
188 views

How to go about combining dropdowns / filter queries?

I'm coming up short with my googling here. (As 'filter' in wordpress always turns up more content related info). Anyway, my situation is this: I have Categories, Tags, Authors and Archive dropdowns ...
1
vote
1answer
519 views

How do i calculate the total of values of custom fields in custom post types?

So the title is a bit unclear, but here is what i have: Custom post type: Projects Custom post type: Investments        + Custom field: Amount And i have one page ...
1
vote
1answer
77 views

Use wordpress functions in another PHP file

I have created in my theme folder a PHP file named gallery.php. In this file I want to use WP_Query function, but I can't do this because it shows error. Is possible to do this? Thanks in advance!
1
vote
1answer
825 views

Filter Select results based on selection

I am trying to filter which job results are rendered to the page whenever the user changes the select item on my form. The select items are dynamically populated by the code below which assigns them a ...