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
32 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
260 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
80 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
57 views

No content found on page 2 of pagination with 1 post per page

This loop (used on a taxonomy-term archive page) is not paginating correctly. The older/newer links for page 2 are there, but when I click on older, it returns "no content found" (when what I expected ...
1
vote
1answer
131 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
138 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
1answer
141 views

Wordpress Custom Query to show posts from last x years

I have found a way to show all posts from the current year with this code: <?php $today = getdate(); $lastyear = $today[ 'year' ]; $args = array( //'nopaging' => true, 'paged' => ...
1
vote
2answers
209 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
82 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
72 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
87 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
52 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
153 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
383 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
74 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
653 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 ...
1
vote
1answer
35 views

Problems with loop

I have this loop in my index.php: <?php if (have_posts()) : while (have_posts()) : get_template_part( 'post' ); endwhile; endif; ?> which calls ...
1
vote
1answer
754 views

Multiple Loops On Custom Post Type Template?

I'm having some issues adding multiple loops. I have a custom post type (locations) that uses a single page template (single-locations.php). I'm trying to add additional loops to this template that ...
1
vote
1answer
605 views

Using loop pagination on single.php

I want the main front-page loop to show in a section on both index.php AND single.php templates, with pagination. Pagination works fine on the homepage, but not on single posts. This is the code ...
1
vote
1answer
262 views

Pagination go to first page if i'm on last post

I have a custom post type and used get_next_post() and get_previous_post() to create a simple pagination. However i need to create a pagination loop (if that is the correct term). If i'm on the first ...
1
vote
1answer
103 views

Get search.php results in header.php?

I want one image in header.php to change for different pages. The function in header.php looks like that: if(is_archive()): //change image to "Archives" endif; if(is_404()): //change image to ...
1
vote
2answers
268 views

Child_of not displaying all children posts.. via get_posts

I have put together this loop to display all children posts of the desired cat, but i am not getting any of the posts from one of the children cats.. Not sure if i am using the best method to ...
1
vote
2answers
157 views

Query reset problem or flawed code to enable custom post type query

After reading through here and trying various options, I am finally able to get my custom post types 'testimonial' (created with product 'Toolset') to show along with my standard cat/tag queries ...
1
vote
3answers
3k views

Recent posts on a static home page

I want a static home page on my wordpress website, I have already set this up and have a bit of content on it, the next step is I want to have 5 recent posts underneath the content. As a normal page ...
1
vote
1answer
636 views

How to filter posts that belong to a specific category only if that is the only category

I need to filter posts that belong to a category only if that is the only category. For example if my post A belongs to cat1 and I don't want to display posts that belong to cat1, post A won't be ...
1
vote
1answer
242 views

Custom loop with multiple taxonomy queries

Apologies -- new to the stackexchange and actually posted this over in Stack Overflow because I didn't know there was a WP specific joint. My issue-- What I Have: I've got the code for a working ...
1
vote
2answers
293 views

Query Posts Exclude Entire Category

I am using the standard wordpress loop that looks like: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> ...
1
vote
2answers
130 views

Multiple loops are not reset

My lovely colleagues have once again designed something that gives me a hard time getting it in Wordpress. Surprisingly it's something that I have done multiple times before; having recent posts and ...
1
vote
1answer
115 views

Posts in loop displaying all taxonomies

I have a loop set up to display projects with two types of taxonomies attached to each. My issue is that within the loop I have set up a function to select specific posts to attach different ...
1
vote
2answers
111 views

I would like to have different styles for my posts based on the content of each post

Here is my wordpress theme to check out(its not completely finished): http://benlevywebdesign.com/wordpress/ This is my first time working with php/wordpress and making themes so keep that in mind. I ...
1
vote
2answers
191 views

Having a Function Inside of the Loop

I am trying to make a frontend product editor for WooCommerce, and have a loop that returns all of the products for the current user. I am trying to use gravity forms as the editor, so a single ...
1
vote
1answer
338 views

Most recent post from another database

I am trying to add the most recent post from another Wordpress database (on the same server in all actuality), but am getting the following error: Fatal error: Call to undefined method ...
1
vote
1answer
866 views

Show a list of recently viewed posts to a user

I have a lot of video posts on my site and I'm looking to show the user a list of posts they've recently viewed. I'm guessing the best route is to just add the post id to an array in their usermeta ...
1
vote
1answer
128 views

Checking if Post Title is Unique as Loop Criteria

I'm trying to make a seemingly simple bit of php (it output's to a Gravity Forms field, but that's basically irrelevant). I'm using Gravity Forms to create posts, which I can do easily, however I ...
1
vote
2answers
184 views

wp_tag_cloud() and the_taxonomies() work but not the_tag()

wp_tag_cloud() and the_taxonomies() work in a widget I built but I can not get the_tags() to work. I want to display the tags assigned to the current post. I built a widget to do this. the widget ...
1
vote
3answers
776 views

Custom post type not displaying content from single-{custom post type} page

I am trying to create a custom post type with taxonomy and a shortcode for my custom search in a plugin.When I activate my plugin I see my CPT and taxonomy on dashboard. But when I publish the post I ...
1
vote
1answer
108 views

Displaying Latest Posts on a Page

I am trying to create a loop to display the title and excerpt of each blog post onto a page that isn't my index page. The in-progress demo site is here: http://thewestharbour.com/mypakage/ On the ...
1
vote
1answer
66 views

How to add “time” data this?

I am using this simple snippets to get post view count for a long time I was wondering if we can add a "time" data ? Because I would like to show the view of yesterday/ 2 days ago / 2 days ago etc... ...
1
vote
2answers
276 views

Remove W3 Total Cache minified files on custom page outside of WordPress

I have created a page outside my WP network install (following this info from css-tricks) The output of which is used for a Facebook business page tab as a Facebook app. It is working just fine, ...
1
vote
1answer
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
3answers
2k views

Calling custom fields for pages (not posts)

I'm trying to place a small code in my template header.php file. I want to get a custom field value. I'm trying to call custom fields from current page outside of loop, btw. I have no problem doing ...
1
vote
1answer
235 views

Displaying terms based on loop posts?

I have a shortcode that shows a loop for a custom post type: while ( $loop->have_posts() ) : $loop->the_post(); // do something endwhile; Some of the posts are in categories ...
1
vote
1answer
97 views

Sort posts by most recently modified

Is there a way to list posts in the order in which they were modified? For example; A user posts 5 posts (#1 being the oldest and #5 being the newest), by default they would be listed with #5 being ...
1
vote
1answer
462 views

how do i remove posts from a WP_Query so the pagination is right?

I'm using a custom post type and showing 20 of them per page on the homepage. I'm using QP_Query. One custom field for the custom post type (called mixtapes) is a checkbox called "unreleased" (set ...
1
vote
1answer
253 views

Display all posts that were published before full post on single.php

The way I would like my blog to work is a user clicks on a post that was published on 12th March 2012 (for example) they get taken to single.php where the content of that post is displayed as normal. ...
1
vote
1answer
654 views

Running a loop with a custom query string on a custom page template

I made a custom page with a template that is just a loop with custom query string for a list of posts from a specific category but when I view the page it only shows one post with the title being the ...
1
vote
1answer
616 views

posts_per_page & pagination conflict

I have a custom query to display my custom post type. posts_per_page set to '5'. In admin post per page set to '10' (settings => Reading => Blog pages show at most 10 posts) My template lists 5 posts ...
1
vote
1answer
627 views

Loop through child images of a parent for a Nivo Slider

I want to use a Nivo slider to cycle through the children of a parent page one by one, how can I do that? I have the following piece of code that grabs ALL the children of a parent page and displays ...
1
vote
1answer
375 views

Paginated HTML Sitemap

I've got to the point where I needed to break down my HTML Sitemap into several pages. It contained 2000+ links. The big layout was showing all post titles under category names on one page. I decided ...
1
vote
1answer
649 views

Why do themes have `while( have_posts() )` in templates like single.php?

Example: https://github.com/markjaquith/WordPress/blob/master/wp-content/themes/twentyeleven/single.php Isn't single.php's purpose to show single posts?