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)

3
votes
1answer
198 views

Have different number of posts on first page

I need to have a different amount of posts per page on the first page that on the other pages. For example, this is what I need Total posts: 6 First page: showing 3 posts Following page: showing 2 ...
0
votes
2answers
315 views

Display post category in foreach loop with category link

I have the following code to show current author post lists with post thumbnail, post title, post date and post category. function my_get_display_author_posts() { global $authordata, $post; ...
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
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 ...
0
votes
1answer
20 views

Wrong post title displayed from loop

I'm building my own theme. I have a page set for my blog (with a template that I made) which I'd like to just display a few of my posts. It uses the following loop: <?php ...
4
votes
4answers
326 views

Why do themes rely on “The Loop”?

I've been looking at Wordpress themes development recently, and I'm trying to understand why Wordpress is coded with "The Loop", rather than providing an array of posts that you can loop through with ...
0
votes
1answer
16 views

Display all attached image of every post of custom post type and link to original post

I've written a loop that displays all the images that are attached to every single post of a specific post type. The post type is called "atls_events" and I'm outputting an image size called ...
13
votes
4answers
14k views

Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function: <?php $sixtydays = date('Y/m/d', ...
0
votes
1answer
270 views

wpdb inside foreach loop only returns first result - 2 other similar cases found

@Milo Problem solved, found spaces in the array $arrname. I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key ...
0
votes
1answer
19 views

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items ...
21
votes
1answer
14k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
0
votes
1answer
275 views

Add Infinite Scroll to Ajax Loaded Category Query

Update: This has been resolved. See update below. Following a few different online tutorials, I've managed to create a function to modify my post display via Ajax based on a category selected from a ...
0
votes
1answer
422 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
39 views

How to add add more properties to WP_Post object in search results loop

I am using a plugin called Event Organiser, and it seems that it will only append its custom properties to the post object for all other instances of the WordPress loop except the search. Is there a ...
0
votes
1answer
406 views

Create a custom taxonomy template that loops through child categories in term order?

We're building a site that sells Biking Gear We're using the Genesis Theme Framework, and developing a custom child theme. It has a Custom Post Type for Products, made with the "Custom Post Type UI ...
0
votes
1answer
29 views

Why doesn't is_page(id) work in functions.php?

When is code in functions.php executed? Is it during the loop? The following does not work when placed in functions.php (not within a function) : if (is_page( 27 )) { echo 'this is the apply page'; ...
0
votes
1answer
643 views

wp_query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
0
votes
3answers
34 views

How to get name of custom taxonomy

I need to get name of current custom taxonomy in archive.php file when page is showing posts belong to the one of custom taxonomy categories. It's easy do it in WP loop but I need get it in front of ...
0
votes
0answers
8 views

How to add jQuery div element to each image on wp site?

I'm trying to add the "Share" button to each of the attachments inside of the post. I found function that allows to get all attachments on the post: ...
0
votes
0answers
10 views

I'm trying to get post_author and post_content

I'm using foreach ($result as $row) and I can use: <?php echo $row->post_title;?> or <?php echo get_permalink($row->ID);?> and they work fine. But i cannot use : <?php ...
0
votes
1answer
19 views

Loop multiple taxonomy in custom post

I have a custom post called "rock" and taxonomy "genres" i need to filter the posts with tag or something like post_type > taxonomy > taxonomy_tag (tagsss) I can not find a solution :( i have ...
1
vote
4answers
98 views

404 error PageNavi custom type taxonomy | wordpress

I have a custom post type called rock with a custom taxonomy called genero. taxonomy-genero-curiosity.php mypage/Rock/curiosity/ When i click subsequent paginated page links (e.g. [2], [3], ...
2
votes
1answer
127 views

If No Search Results, Show Posts from Alternate Search Query

I have a pretty standard loop which outputs "Sorry, No Posts Found" when a search result comes up empty. if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( ...
0
votes
1answer
28 views

Query all post types but limit to parents

I'm building a site with several post types and am using a single index.php to query the archive for each one in turn. One of these post types is hierarchical and I'd like to just query the parent. I ...
0
votes
1answer
631 views

List post only under the category, exclude child category content

I wanted to list posts which are directly under a category and not inside the "sub category". In other words, I want to hide all the posts which are from "Sub Category" in the Parent category view. ...
0
votes
2answers
305 views

How to modify search.php to not show pages only show posts

I want to modify search.php so that it only shows posts and not pages. Can you help? Here is the loop in search.php: <?php if (have_posts()) : ?> <?php while(have_posts()): the_post(); ...
0
votes
3answers
2k views

Pagination not working on home page

I've a page named "share" with a complex loop that's working perfectly. This page is located at domain.com/share. Now I need to use this page as the home page, so I went to "Settings -> Reading" and ...
0
votes
0answers
26 views

$post breaking container loop

Problem I have a foreach loop grabbing posts inside an advanced custom fields repeater. When it's finished looping through posts it breaks the repeater. I believe the problem is with $post as far as ...
0
votes
1answer
307 views

IF have_posts contains posts from a certain category

This issue is now finally resolved by myself. Find the solution in the end of this post. Question was in short: How can i ask in my WP template, IF the whole array of have_posts contains any post from ...
0
votes
0answers
27 views

archive.php not showing the last post queried [closed]

I have this rare issue. When I visit archive page for a category, it shows all posts but not the last one. If there is only one post in the category, it does not shows any entry. I tried with the ...
-1
votes
0answers
32 views

Snippet to show lowest price in shop page for WooCommerce [closed]

I've set up a shop page on woocommmerce, its displaying all the categories available to choose from. However I can seem to find any threads on how to loop in the the pricing onto the page. I ...
0
votes
0answers
21 views

Popular posts from 7 days loop

I'm trying to create a "loop" which will display Popular Post from a week or any other timeframe. What's the best way of doing it? Also, is it possible to order the posts by views? EDIT: Here is ...
0
votes
1answer
660 views

Listing Specific Categories from Current Post with Depth

I've been on this for sometime and been having a ton of issues to find a proper way to do what I'm trying to achieve. An Example would be as follows: I have a featured Image with a rollover and I ...
0
votes
0answers
18 views

Search for posts with specific tag inside custom page template

I'm developing a Wordpress blog where there are two custom pages - i.e., different from index.php. In there, there are two albums of photos, with the photos listed on a div above. I've put an input ...
0
votes
0answers
17 views

Custom Loop and the_title();

I have used custom loop to process posts however, the loop cannot get the right title or the custom fields. I am using ACF plugin The weird thing is that the loop gets the right content through ...
1
vote
1answer
2k views

ajax for filtering posts by category in wordpress loops

I've been looking around for a way to filter my posts on http://www.waziproject.com/wazimagazine/ without reloading the page. So my question is if anyone can help me out to turn the following into a ...
0
votes
1answer
35 views

How to do a loop inside a loop?

I'm trying to get posts from a custom posts using WP_Query. <ul> <?php $query1 = query_posts( array( 'posts_per_page' => -1, 'post_type' => array('specialties') )); ...
0
votes
0answers
24 views

index.php is only displaying current month's posts?

The blog portion of my WordPress site (a corporate website) utilizes index.php as the default blog page. However, while the page properly shows the PAGING for the other 40+ pages of blog posts, the ...
0
votes
0answers
49 views

Stuck in a Redirect Loop

My Wordpress site is stuck in a redirect loop and I can't now access it. I recently purchased an SSL certificate which my site host says is installed correctly and points to the correct place. I ...
0
votes
0answers
17 views

First post separate from loop pagination count? [duplicate]

What seemed trivial at first has gotten me completely stumped. Here's what I have in my index.php and credit to this answer if ( is_home() && !is_paged()){ the_post(); ...
0
votes
0answers
15 views

Order main loop by category and then post_date

I'm creating an "announcement" post category. I'd like those posts (using the category id) to appear first in the main loop sorted by post_date desc and then the rest of the posts sorted by post_date ...
0
votes
1answer
2k views

Conditional two level dropdown filter for custom post type

I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a ...
0
votes
1answer
27 views

pre_get_posts main_query not displaying after applying tax_query filters

Maybe someone can help me identify a problem I am experiencing with the pre_get_posts action. I have used the same code in another project before and it worked fine. I even went through line by line ...
0
votes
2answers
402 views

Display post thumbnail for specific category outside the loop

I'm building a theme that features a section wherein I'd like to have the single most recent post's thumbnail of a single category displayed between the header and blog sections. Something like ...
10
votes
4answers
3k views

Display all posts starting with given letter?

I'm trying to build Wordpress based dictionary, basically it will have 26 pages (one for each letter): A B C ... X Y Z And every page will display all posts starting with given letter, so after ...
0
votes
2answers
1k views

Pagination on category.php and tag.php not working

i'm using a query-loop on my template pages like this: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); ...
0
votes
1answer
430 views

Custom post-type's pagination not working in category.php

I have this code to the file category.php : <?php get_header(); ?> <div id="content"> <div id="all"> <div id="todo"> <?php $my_query = null; $paged = ...
0
votes
1answer
388 views

Video post format, extra content breaks video embed

I am using the content-video.php include to show the latest video post on my homepage. The include only shows the video from the post and not the rest of the content, which works well. My problem is, ...
0
votes
1answer
22 views

While loop with an exception after a count is reached

I'm trying to edit the tag.php page so that it displays all tagged posts (as it normally does) 'but' I want to call a function after the 3rd post in the loop. Current Code <?php /* The loop */ ...
0
votes
0answers
23 views

How to add an if statement for one of the custom fields on the following loop?

I have a bunch of custom fields on one of my post types, that is displayed randomly but in a fixed order. The names of the custom fields are always the same, and for every loop there is an increasing ...