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)

0
votes
1answer
16 views

Getting the Most Recent Posts from Multiple Categories

I've got a page (page, not post) that near the bottom of the page I want to get the most recent 15 posts from a set of categories. I'm new to doing this and thought I was doing it correctly. The div ...
0
votes
1answer
29 views

have_posts() return false on single post

I'm a little bit confused with the use of the Loop. This is my first theme and i just use index.php currently to display all my pages. It works fine for pages but have_posts return false when i try to ...
1
vote
3answers
108 views

get_the_content not working in loop?

I am trying to modify my loop to save post data by category. I found some code on this site that saved the post's titles based on their categories and tried to modify this to save the post's content. ...
1
vote
2answers
41 views

if ( is_home() && ! is_front_page() )

I see the following code a lot in index.php files. I understand that is_front_page() returns true when viewing the Site Front Page (whether displaying the blog posts index or a static page), while ...
0
votes
0answers
40 views

wp_get_archives doesn't work with 'post_type' with WordPress 4.5

wp_get_archives support the post_type parameter from 4.4.0, so I decided to add a <select> on the cpt's archive page. Unfortunately wp_get_archives returns with NULL. Do you have any idea ...
0
votes
0answers
31 views

Display category name only once inside loop

I have been researching on how I can output the category name on a wordpress loop for custom post only to display only once. If there are any posts under the same category, the category name will not ...
0
votes
1answer
36 views

Wp_query with 2 meta keys and array of meta values

Hi in my post_type=shop i have 2 meta keys and array of values Custom fields Name Values cu_status pending,processing,completed cu_date 12-Jan-2016 , 13-Jan-2016, ...... any ...
0
votes
0answers
14 views

List posts that are geotagged within a certain area

I'd like to geotag some post on WP with latitude and longitude in a custom field. It's very easy to show a map with this data but what if I want to show all the posts that are geotagged, let say, in a ...
0
votes
0answers
39 views

Omitting the latest entry with custom type and taxonomy term from the loop

My agency has inherited a client with a customized theme provided to them from a separate agency, which farmed the work to another agency off-shore. The documentation for this theme is non-existent ...
0
votes
1answer
49 views

meta_query not working properly

I'm trying to run a query that only displays items that meet a condition in an Advanced Custom Fields select box, but I'm getting nothing. Here's my query. Any help would be appreciated: <?php ...
0
votes
1answer
45 views

How to make a wordpress loop file that displays posts based on certain conditions

Am recently trying to learn the framework aspect of WordPress,so i want to build a user homepage that only displays posts from other registered users, but the posts that will be displayed will have to ...
0
votes
2answers
36 views

How to Order By Two Custom Fields?

Note : This is not a duplicate question to If value present, order posts by two consecutive custom fields. After filtering a custom filed, I need to order by another custom filed. (The above link ...
1
vote
1answer
59 views

Wordpress have_posts() return false but count says “3”

The situation is this: I have created a custom post type which works perfectly, now I want to create a specific archive page template for the taxonomies of this post type. I duplicated the ...
-2
votes
2answers
43 views

How to create a loop where loop changes every post?

How can I create a type of loop in WordPress where an image moves left or right for each post? I.e. first post image will be left, second post image will go right, third post image will go left, and ...
0
votes
1answer
32 views

Adding a html class based on post count

I'm creating a grid of columns and need to add a css class to each column at the end of the loop based on the amount of posts returned so it returns something like this: <div ...
0
votes
2answers
61 views

How to display post list in a table layout (multiple queries in single loop)

I am setting up an events page for my website. This page is using a loop to display a list of acts performing at different venues month-by-month. When a viewer comes to the page, they use a simple ...
0
votes
0answers
15 views

Loop through author and edit post tags

I'm setting up a 'free marketplace' for a friend based on wordpress and a woocommerce theme (makery). Each user has his own shop and products. Both the shop and products are custom posts that belong ...
0
votes
1answer
20 views

How can I make this iterative conditional within the Loop work via function?

I want an element to appear within the Loop, but only at certain points. I can supply the condition - in the form of a "flag" that gets set when the condition is fulfilled, preventing further ...
1
vote
1answer
75 views

Custom Post Type Pagination Not Working On Archive Page

I've spent the last 3 hours trying to get pagination to show up on my custom post type archive page. I sort of understand that pagination only works with a default loop and once you modify the loop, ...
1
vote
0answers
26 views

Infinite Scroll and DFP

Well , I'm trying the next loop to make work DFP in an Infinite Scroll. I thought that if I change the name of the Slot I could get the banner shown, so I tried this: <!-- DFP Controller --> ...
0
votes
1answer
26 views

Posts Per Page is Not Returning Correct Number

I have a single.php with 3 loops one the page (related posts, latest posts and the actual content). All loops are using the wp_reset_postdata(); at the end. For some reason my post_per_page ...
-1
votes
1answer
16 views

How to separate posts loop in to two columns? [duplicate]

I need to separate WordPress posts loop in to 2 columns , left ( all odds ) and right ( all evens ) . Currently I am doing this with 2 separate loops but would like to make it with one and would ...
0
votes
2answers
66 views

Pagination Not working on Home Page with 2 Query

I have two loops in home page (index.php) <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 3, ); $another_query = new WP_Query($args); if( ...
0
votes
1answer
22 views

Exclude current custom post on single post

I'm trying to exclude the current custom post that is viewed from a list. I've tried with exclude but it still displays it. Here is the code I have on single-works.php: <?php $currentID = ...
0
votes
0answers
30 views

why does “else” break “if” statement?

I dont understand why this is happening. The winning code is a hash of the post ID. A link is sent to email with the winning code and a link to verify that youre the winner. Now here is where ...
-1
votes
2answers
65 views

How to create a loop that will display one post and stop?

I am trying to create a part on my wordpress theme that will only display one featured post. I have installed this plugin - https://wordpress.org/plugins/featured-post/ . I know I am supposed to ...
0
votes
2answers
47 views

Display specific page (that is child) content on parent page

I have problem displaying child page content on parent page (both static). I can display other page content but only if on same level. It dosent work in relation parent - child. <?php ...
0
votes
1answer
35 views

active link for most recent post on vertical tabs

I'm trying to add the css class .is-active to my vertical tab links inside my loop. By default, the page loads the most recent post first. How can I make most recent tab/post active with .is-active? ...
0
votes
1answer
51 views

WooCommerce custom loop pagination on front page

I'm having custom page template that I use as front page of my theme. In that page i have section which lists woocommerce products using custom loop. I want to insert next posts pagination to that ...
1
vote
0answers
18 views

Two loops on different pages do the same thing, but only one page works

I want to verify a code sent in an email. I do it once to verify your email when you signup and again if youre the winner of the contest. Since its basically the same thing, I reused the same code ...
0
votes
0answers
23 views

Archive page: how to orderby category and then by author?

Is it possible to display an archive page ordering its articles by (sub)categories first and by author (alphabetically) as second level order? What do I need to modify and where?
0
votes
0answers
25 views

loop authors with permalinks to posts for custom post type

I have created a custom post type called "adoptions", I have created an adoption-page.php and a single-adoptions.php. In the adoptions-page.php I have loop which displays all the current post from ...
0
votes
0answers
58 views

WordPress multiple loops on home optimization

I am running an News Website based on WordPress with several plug-ins, including W3C Total Cache on my VPS (Nginx + PHP-FPM) server. The code of our home.php is: <!-- STICKY POSTS ...
0
votes
1answer
27 views

Loop code is displaying pages but not actual posts

This code only returns the name of a custom page I built -home. Why is it returning the page title? I want to display posts. <?php if ( have_posts() ) { while ( have_posts() ) { ...
0
votes
0answers
33 views

Sticky post to top of category

I use this code: add_filter('the_posts', 'bump_sticky_posts_to_top'); function bump_sticky_posts_to_top($posts) { foreach($posts as $i => $post) { if(is_sticky($post->ID)) { ...
1
vote
1answer
24 views

get_posts that match a user-specified value on a page

On each page, I want the admin to choose which case history post summaries will be displayed depending on the post category. My code below works but it is very clunky if you have lots of categories. ...
0
votes
1answer
26 views

List Authors For Current Category

I want to list all unique authors that have posts in the current category. My code (location: wp-content/themes/custom-theme/category.php) <div class="container"> <div class="row"> ...
0
votes
0answers
30 views

WP Pagenavi showing only the first two pages without error

I'm trying to show a complete list of the posts, so I included pagination. The problem is that only it's possible to access the first two pages. If I try accessing the 3rd page(/page/3) for example, I ...
1
vote
2answers
56 views

Display different content on homepage depending on post type

In the home page, I have a custom loop for displaying different post type content. I have this loop on my index.php $loop = new WP_Query( array( 'post_type' => array('photo', 'video', 'web'), ...
0
votes
1answer
36 views

Infinite Loop after Genesis Theme Upgrade

I'm running WordPress on Microsoft Azure, and I've been having a lot of timeout errors any time I try to install or update plugins/themes. (I'm using a custom child theme, based on Genesis.) Today, I ...
0
votes
1answer
49 views

ACF loops false value with repeater and checkbox

I have an ACF repeater field setup on a page and within the subfields I have a True/False checkbox. So far, if the box is checked, it will show the fields. If not then it will not. However, the one ...
0
votes
0answers
16 views

How can I manually set an order for specific category in Woocommerce?

I have a shop page in Woocommerce where I manually put the order number through the product page. This is fine when they view the entire collection. What I want to do is set a second order number for ...
0
votes
1answer
31 views

Modify widget to output posts in custom order

I am using a widget of the Smartline-Lite theme called "Smartline_Category_Posts_Grid_Widget" that lists posts of a chosen category on the front page. I have set the number of posts to 10. The widget ...
0
votes
2answers
26 views

Can I use both a custom excerpt and a trimmed excerpt?

For each post, I use the custom excerpt field to write a custom excerpt (180 characters max) for each of my posts, which I use as the meta description of my post for SEO. When I show a list of my ...
3
votes
2answers
66 views

Ignore post by meta value in the main query

I use this function to insert at the beginning of the loop two post at my convenience (with meta key and value) add_filter( 'posts_results', 'insert_post_wpse_96347', 10, 2 ); function ...
0
votes
1answer
223 views

How to get the first image gallery of a product in woocommerce in a loop

I want to diplay a product with product image, and when visitor hover that image, will change to first image from product gallery I am using this code to display the image gallery, but displayed all ...
0
votes
0answers
15 views

Query a custom post type from a different WordPress install?

I have a client who would like to only create his items on one domain, but have a specific taxonomy of that custom post type display on a different domain (this is not multi-site...they are separate ...
0
votes
0answers
22 views

Use audio file like image featured

Attempt to get the url of an audio file in post content to display in the loop of the home page. I can only get it if the file is uploaded at the time of creating the post, but if I go to a post ...
1
vote
1answer
61 views

How do I get the category URL from get_the_category?

My loop below shows the latest 4 posts from the same category as the post currently being viewed. Its located within single.php. I'm trying to get the URL of that same category so I can link back to ...
0
votes
0answers
14 views

why is the value of one field different from another if they are filled with the same variable?

A form is submitted containing a users email address. When the form is submitted, the page that processes the form creates a new post, and it sets the value of the custom meta field called 'entryCode' ...