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
368 views

Create a Loop with Posts Ordered by Most Recent Comments

Using query_posts, how can I order the list of posts so the ones with the most recent comments are at the top? I'm looking for something similar to how Questions here on SE are ordered when you ...
0
votes
0answers
31 views

Get custom post type's fields in a while loop as variables

I'm working on a page that shows the name of a lot of products (custom post type), and when the user clicks on the name he can see some product information. It's something like this: Main page with ...
0
votes
1answer
31 views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
0
votes
0answers
7 views

Popular posts with Varnish ESI

I am trying to get Varnish ESI to work with displaying the most viewed posts on a new blog I am working on. Here is my current script; In theme file: <esi:remove> <?php get_template_part( ...
0
votes
0answers
14 views

Retrieving category pages from subcategory returns empty sets

I've a category overview page. It shows its subcategories. These subcategories have subsubcategories which are pages too. I'd like to retrieve those (title, permalink and excerpt) but so far my ...
0
votes
0answers
16 views

Exclude Featured Image Attachments from Wordpress Search Results

I'd like my search.php page to show all attachments except featured images (because they appear as duplicates of the posts that use them). I have seen some examples that do this for a query, but ...
0
votes
1answer
18 views

Show one item per category of a custom post type

I'm having a custom type called portfolio with different categories. I want to display all my categories except one. I only want to show one item per category on my page. I'm been busting my butt on ...
0
votes
0answers
17 views

Display Posts in Admin Page

I create a admin page. Now I need to display posts in that page. Should I use WP_Query or get_posts()? (Pagination should be there) Note : I have read When should you use WP_Query vs query_posts() ...
0
votes
0answers
13 views

add date of most recent custom post type

I have a custom post type called products, it is categorized by a custom taxonomy called product_category. I'm trying to have a "last updated on" note on the taxonomy archive pages. I was hoping ...
0
votes
0answers
11 views

How to query post from sub-categories on category archive and display posts?

On a custom taxonomy archive from the taxonomy called 'books' (taxonomy-books.php) I want to list all subcategories that are assigned to the parent category. And then for each subcategory I want to ...
0
votes
1answer
12 views

Highlight specific user with custom field value

I'm working on a Wordpress project with some friends from school. But there's a problem with highlighting a user on the website. The idea is to create a 'User of the month' thing. In the user ...
0
votes
0answers
26 views

How can I add pagination to my loop? [duplicate]

That's my current loop: <main id="main"> <?php // the query $args = array('posts_per_page' => 10 ); $the_query = new WP_Query( $args ); ?> ...
0
votes
1answer
20 views

Attachment Metadata inside of Loop

Basically, I'm trying to call attachment info to display withing a loop, for use in an image gallery. I know I need to use wp_prepare_attachment_for_js($attachment_id) but I can't seem to get anything ...
0
votes
0answers
13 views

Sticky posts with conditional taxonomy check

I have two different taxonomies with the same terms. so let's say: Places: Russia, India, Jamaica. Sticky Places: Russia, India, Jamaica. Now i want to create a loop which checks if a post has two ...
0
votes
2answers
24 views

Display post formats differently on index.php (loop in function)

I'm a newbie-- please bare with my ignorance here. I've been trying to read other questions about this but so far I can't wrap my head around this. I'm hoping to display post formats differently on ...
0
votes
1answer
28 views

Wordpress Request Post All Post ID in a Loop? [closed]

I would like to ask if there's a way on WordPress to get fetch all of the page's Field?... I am using a Advance Custom Field Plugin and would like to fetch data's from fields inputted over those ...
0
votes
0answers
35 views

WooCommerce: Making a loop create divs of categories, with category products inside

I have a php/wp script written which in theory should print a div with a category name, description, and all of its products inside. The code looks like this: <?php $args2 = array( 'taxonomy' ...
0
votes
1answer
48 views

Loop 1 user randomly

At the moment I am using wp_user_query to loop users from a specific role(leden) on a webpage. For the overview page this is working fine, but on my homepage I want to feature one random user. I was ...
0
votes
0answers
20 views

Duplicate Custom Posts

I am having trouble with a site duplicating posts. It will duplicate "page 2" on "page 3" and it will duplicate one other specific post. It also isn't showing all the posts, but I think this has to do ...
0
votes
0answers
16 views

WordPress loop by three meta values with random order

We have three custom fields with names plan_name1,plan_name2 and plan_name3. Need to check if these meta keys has values (1,2,3) OR (2,3,1) OR (1,3,2) OR (2,1,3) OR (3,2,1) OR (3,1,2) We mean ...
0
votes
0answers
21 views

Terms showing empty inside a loop

I have the following problem: I have 2 taxonomies that belongs to a custom post type What i want to do: Loop = taxonomy 1 loop = taxonomy 2 loop = post type My code works but, it shows ...
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
29 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
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
38 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
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 ...
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 ...
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 ...
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
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
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)) { ...
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
29 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 ...
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
46 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
1answer
213 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 ...
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' ...
0
votes
1answer
76 views

2 Loops on one page - pagination of 2nd loop ignore array of excluded posts

I have 2 loop on one page. First one shows 11 recent posts in rand order and pushes each post ID into do_not_duplicatearray. $argsRandom = array( 'numberposts' => 11, 'fields' => 'ids' ...
0
votes
1answer
50 views

Show Posts By Custom Field

I’d like to add 2 custom fields to my posts: show_post_on_home_page home_page_posts_order_sequence I then want my home page to show only the posts where show_on_home_page == true, ordered by ...
0
votes
0answers
15 views

The Loop doesn't work when using RewriteRule

I am using .htaccess RewriteRule on my page. When user goes to /news RewriteRule actually loads /?nav=news On that page, I use The Wordpress Loop to show recent posts if (have_posts()) { ...
0
votes
0answers
26 views

Loop through custom post type taxonomies

I have created custom post type products and I want to show categories on products archive. I have this code <div class="container"> <div class="boxes"> <?php $cat_args = array( ...