Skip to main content

Questions tagged [loop]

The core of the WordPress query, the loop offers an easy way to access post information and display it on your website.

Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

Advanced Custom Fields in WP_Query: Href Returning Empty

I'm still learning the ropes of PHP so please bear with me! So basically I have an ACF URL field "author_link" that I want to generate on a "table of contents" page in a list ...
Hex1189's user avatar
0 votes
0 answers
9 views

Add "New" Sale badge to products in WooCommerce based on creation date

I tried to add the label "new" to products created within the last 30 days by adding an action to the "woocommerce_before_shop_loop_item" hook. However, it's not working. function ...
Harry Nguyen's user avatar
0 votes
1 answer
21 views

How to get total posts count for each date?

function test_dashboard_content() { $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish', 'date_query' => array( 'after' => '...
WPdummy's user avatar
  • 23
0 votes
1 answer
24 views

How to make FSE's query loop to order by comments number?

I apologise deeply if this topic already been answered here in the past. I have searched for an answer and couldn't find. The question is regarding Gutenberg, FSE editor, block theme: is it possible ...
neoswf's user avatar
  • 125
0 votes
0 answers
51 views

Elementor : display only one category in loop grid

I'm having some issues with the loop grid in Elementor. I have two categories on my website and created two loop grids. I want to display only one category in each loop grid so I used some CSS to my ...
Laura's user avatar
  • 1
0 votes
0 answers
11 views

WordPress current post functions inside loop doesn't work anymore, are they incompatible with php 8.0?

I recently update php from 7.4 to 8.0 , since many functions doesn't work anymore ! I don't know if it's related but I have tried many solutions and none of them works. Using (get_...) , the_title, ...
imagIne's user avatar
  • 83
0 votes
1 answer
26 views

Global $post value outside the loop

On a category archive page, in a filter called from a block outside a loop, I noticed that the get_post function with a null first parameter returns the first loop's post. Is it supposed to return ...
challet's user avatar
  • 111
0 votes
0 answers
5 views

Show Featured products with custom taxonomy template

I have a custom taxonomy template / archive called taxonomy-brand.php and this loops fine and shows the products that have the same "brand" taxonomy, trouble is I want to have a second loop ...
user1681836's user avatar
0 votes
0 answers
9 views

Displaying Car Prices from Page Listings on Each Post Car Pages (Post Type) Using ACF

I've introduced a new post type in WordPress named "car" where I showcase the specifications of various cars. I've extensively utilized Advanced Custom Fields (ACF) with numerous fields for ...
och's user avatar
  • 39
1 vote
0 answers
8 views

Add More Featured Data Not Sending to Database

I have made one form which is two step based. also i have added feature add more. So when you add click show same filed duplicate on step two. Problem---- When i'm trying to send data by (add more) ...
Atiq Rev's user avatar
1 vote
0 answers
19 views

Custom loop menu is not working

I am using the below code to create a custom WordPress menu for mobile. With this code, nothing is return. Even the menu is not retrieving. Can anyone assist me with this? This is a multilingual ...
user2584538's user avatar
0 votes
2 answers
26 views

List of published post dates only outputting one date

I have the following, which works, but only returns a single post date: function test() { $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'post_status' => 'publish' ); $...
WPdummy's user avatar
  • 23
1 vote
1 answer
98 views

Using Query Loop Block to list all posts under each category

I am using Query Loop Block to list all posts under a custom post type. But I want to display all posts under each individual category, is that possible using query block? Something like this: ...
Rain Man's user avatar
  • 164
0 votes
1 answer
15 views

Loop through categores and posts of a custom post type in WordPress?

I've created a custom post type called faq in WordPress and I've created a few categories for it - like "Billing" and "Shipping". My end goal is to create multiple FAQ "Posts&...
Sackadelic's user avatar
0 votes
0 answers
19 views

How to display only posts from the last day with posts published?

The goal is to show today's published posts or, if there's none, the last day's with posts published posts. I found this old question, but the code suggested uses query_posts. I'd like to use WP_Query....
Rodrigo G.'s user avatar
0 votes
0 answers
23 views

Default post showing more than intended

I have a ajax set up where I am loading post categories via ajax request on click of a button. I have a default query that is loaded for when the ajax filter is not set so a default state. It should ...
Beep's user avatar
  • 29
0 votes
1 answer
24 views

Splitting query results, on the frontend, into separate sections based on meta value without multiple loops?

I have a query, sorted by a meta field, and I am trying to figure out how to split the query into different sections based on the meta field. Essentially I want there to be an h2 and a ul for each ...
user13286's user avatar
  • 255
1 vote
1 answer
59 views

Grouping posts by 2 different taxonomies

I have the following issue: I have a custom post type (books) with the following taxonomies (1) Categories and (2) Series. Within categories, I have 4 genre sub categories and all books are divided ...
K. Glover's user avatar
0 votes
1 answer
45 views

Query Multiple Post Types and Paginate Newly Created List

I know this has be asked several times but i cant seem to find the answer anywhere. My site has a resources page which is my archive for all resources (archive-resources.php). I'm trying to also ...
user2402492's user avatar
0 votes
1 answer
75 views

Multiple queries and pagination

I have a homepage and an archive page where I call a template part to have a hero section for the most recent posts, and then loop through the remaining posts as usual. Essentially I don't want to ...
lastnoob's user avatar
  • 153
0 votes
1 answer
17 views

Unexpected warning message to my WordPress posts which group and listed out by year

I have my WordPress posts looped and listed out by year successfully. However, I am unsure why I still received a warning message. Warning: Undefined variable $year_check Below are the codes that I ...
Danc Chan's user avatar
0 votes
1 answer
32 views

Different date time in results of search

In my search.php file i have a loop which succesfuly gives list of search query. global $wp_query; $total_results = $wp_query->posts; if ( $total_results ) : foreach ( $...
X9DESIGN's user avatar
  • 159
0 votes
0 answers
41 views

Get last post in loop in Wordpress

i have a loop in wp <?php $count = 0; //set up counter variable $args = array( 'date_query' => array( array( 'after' => array( 'year' => 2015, ...
janw's user avatar
  • 1
0 votes
0 answers
25 views

How to pull through page title depending on which radio button is selected on the specific page?

I'm pretty new to Wordpress, ACF and PHP. I am currently working on a project, the website has 11 different sports centres all with different sport/activities, on each centre they will have a sidebar ...
jonnyplat's user avatar
-1 votes
1 answer
106 views

button onclick with get_post_permalink

I developed a custom post type. On my archive page for each post there is a <button>. The problem is that I can't put the link to the post in question. My button is in my loop. <button type=&...
Thica's user avatar
  • 17
0 votes
1 answer
41 views

Loop a Single Taxonomy and Output all Posts Associated (but also show a message for empty ones)

I have a custom post type for Vacancies, with a Taxonomy of Location set up. What I've achieved is looping through all Locations and then showing underneath associated posts. Update: Thanks to @...
AP_19's user avatar
  • 3
0 votes
1 answer
54 views

How to assign to each output values from foreach loop to a meta_key?

For a custom plugin with add start and end date of event/post, I must generate several datetime with the same meta key to compare the period of event with the period of weeks. I my case I'm obliged to ...
imagIne's user avatar
  • 83
0 votes
0 answers
119 views

Getting the correct post ID in Wordpress query loop

I'm trying to add custom field values inside a Wordpress query loop, so that I can have a list of titles, excerpts, and extras like start ratings in the loop results. I want to use something like echo ...
Marko's user avatar
  • 1
0 votes
1 answer
28 views

Create side bar widget showing list of years as hyperlinks for a custom post type

I have a WP site using Elementor Pro. I have created a Custom Post Type called "Meeting" I have created an archive page for "Meetings" using a Loop Grid To display the post ...
Jasperjon's user avatar
  • 101
1 vote
0 answers
49 views

How to Filter the Custom term loop based on dropdown

I had created on Custom Post Type 'resource', which has 4 taxonomies ('type', 'sector', 'industry', 'rtag') now i had added 45 posts in following manners Type - Brochure, Infographic, Research Paper, ...
Bhargav Joshi's user avatar
0 votes
0 answers
26 views

author archives, showing all custom post types, problem on pagination

Please, look at the link to the page I need support with. This is a website where several “authors” make their reviews on books or create some original posts. This page shows “Badges” which are all ...
Ioria's user avatar
  • 29
0 votes
1 answer
36 views

Giving each loop post unique numbers so that Wordpress would treat separately

So I got this code right now. The problem I get is that it executes only for the first video. I know I need to give each loop post a unique number in order for WordPress to treat them separately. Same ...
RaymondM's user avatar
0 votes
0 answers
49 views

Short custom plugin to send email to users

I have created a very short plugin that is working with a cron job running the below function once every 3 months. I will explain the steps inside the function: Fetching Producers(a list of users ...
Honoluluman's user avatar
0 votes
1 answer
77 views

Is it possible to use the_post 2 times in one loop

I have a page on which I want to display all my posts from my custom post type, which I am able to do in a single column. However, I want to display the posts in 2 columns. For this, I will need two ...
Romit's user avatar
  • 1
0 votes
1 answer
831 views

get_the_ID() retrieves same ID on Gutenberg's Query Loop

I'm using Gutenberg editor and I want to add a shortcode (using XYZ PHP Code) that uses the post id to retrieve certain ACF value. I'm editing the home page where the last blog posts are shown, but I ...
Alvaro's user avatar
  • 131
0 votes
1 answer
35 views

How to show correct td of table tags in wp_query loop

I Have this loop: <?php $post_ids_fetched = array(347, 258); $editor = new WP_Query( array( 'posts_per_page'=>4, 'post_type'=> 'earth', 'post__in' =&...
och's user avatar
  • 39
0 votes
1 answer
116 views

SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop

I'm creating a template for a custom post type & I'm trying to add a WP Query loop displaying specific Divi projects filtered by tag. I'm inserting the loop using a shortcode, & I've ...
megseoh's user avatar
  • 31
1 vote
0 answers
31 views

Wishlist Icon in Divi Blog module (loop)

I use the Divi Blog module (loop), but it lacks some functions. So with a childtheme and code I retrieve post meta in the Divi Blog Module, thats all working fine. But, I also want a working wishlist ...
Joyce's user avatar
  • 11
0 votes
2 answers
259 views

ACF - How to get custom taxonomy term image field

I have loop that displays only the direct children of a term on a taxonomy page. I also have image field, attached to custom taxonomy. Now, I want to display image in my page template: <?php $...
och's user avatar
  • 39
0 votes
0 answers
16 views

Why does my search query loop double on the second element?

I'm writing a custom query for a wordpress loop that should match and filter elements into three categories 'premium', 'nachhaltig', 'guenstig'. I do that with a counting variable: $search_count. At ...
Lisa's user avatar
  • 13
0 votes
1 answer
38 views

Unexpected number of loops in while

I wanted to test how many times a while would loop through a query array. $WatchListArgs = array( 'post_type' => 'post', 'post_status' => 'publish', 'category__and' => array(...
Nora McDougall-Collins's user avatar
0 votes
0 answers
20 views

wp_query loop how to also display post second time with specific condition

I filtered posts by period : from "current week"* , from * + 1 (following 2nd week), from * + 1 + 2 (following 3rd and 4th week) and from 1st day of current month * 12 month. For the last ...
imagIne's user avatar
  • 83
0 votes
0 answers
41 views

Playlist shortcode, prevent repeat disable

I'm using the WordPress playlist shortcode to present a few audio samples on a given page. For example: [playlist images="false" artists="false" ids="542,543"] The ...
Tim's user avatar
  • 1
0 votes
0 answers
84 views

how to replace '/' symbol to 'OF' text from fraction element of elementor carousel

I have tried many css using :after and :before but / is not replaced with OF text. <div class="swiper-pagination swiper-pagination-fraction swiper-pagination-horizontal"> <span ...
RAJ Technology's user avatar
0 votes
0 answers
22 views

Row loop inside different columns

Help to create a wordpress loop with the row inside different columns from 2 categories
Jobin Jose V's user avatar
0 votes
1 answer
12 views

I’m Trying to Separate the First Post From the Rest of the Loop

The layout I’m marking up and styling calls for the first post to be full width while the rest of the posts are not. Here’s my block of code: <main> <?php // Define how the loop will fetch ...
Samuel Bacay's user avatar
1 vote
0 answers
42 views

Post Query with Meta Query no longer working

I am working on a magazine website that has a large amount of posts, submissions, etc. There is about 60K+ posts/submissions on the site right now. I don't know when it happened specifically, but ...
Devon Regular's user avatar
0 votes
1 answer
210 views

How do I display WooCommerce products in my query to rows of 3?

I have created a WooCommerce search plugin. It fetches products, however it only displays the products as one per row. How can I amend my query to display 3 products per row? Here is the function: ...
SavPhill's user avatar
  • 118
0 votes
1 answer
23 views

How to get posts by a certain author in inner loop using outer loop variable or post title WordPress

I am working on a WordPress site with staff bio pages. At the bottom of the page, I would like to include their most recent blog posts (if they have any). I have an outer loop that pulls the fields ...
Allyson Smith's user avatar
0 votes
2 answers
469 views

Users as team members through a loop in elementor

I am trying to create a loop in Elementor's theme builder that will display each user with the role of the Contributor or Author. I.E. When the admin of the website will add a new user with the above ...
Andrei Dombrov's user avatar

1
2 3 4 5
67