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
9 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
14 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
22 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
22 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
57 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
36 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
45 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
  • 143
0 votes
1 answer
16 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
30 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
38 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
23 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
66 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
35 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
50 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
  • 53
0 votes
0 answers
79 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
34 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
24 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
35 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
47 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
60 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
535 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
29 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
97 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
  • 21
1 vote
0 answers
28 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
150 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
37 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
18 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
  • 53
0 votes
0 answers
39 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
60 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
20 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
9 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
0 votes
0 answers
100 views

Loop through Redux option framework repeater field

I am using Repeater field of Redux Framework in WordPress. I have created the repeater field and assigned the data. Now I am trying to display those data in front end. But I am not getting how can I ...
Milan Bastola's user avatar
1 vote
0 answers
35 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
184 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
22 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
1 answer
260 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
0 votes
0 answers
61 views

How can I display custom post type grouped by a "select" cutom field value?

I have a custom post type. I use ACF for the layout of this custom post type. In ACF, the field is called "temoignage_category", the field type is a "select" and in the "...
blogob's user avatar
  • 137
1 vote
1 answer
29 views

How can I incldue a "private" post type in a loop for public users?

I have a post type that I've registered using "public" => false, "publicly_queryable" => true, because I don't want singles, but I do want these posts to show up on a custom ...
JacobTheDev's user avatar
  • 1,221
0 votes
1 answer
52 views

How can I create an entirely new, separate display of posts?

I'm not even sure how to ask this question… :( I want to create a new way to view my posts, where they are paged by weeks. (That is to say, a "page" is not a specific number of posts.) I ...
Craig Constantine's user avatar
0 votes
0 answers
15 views

Group search results by post type, but having a unique heading for each section?

I've been struggling to make it work. This code works and returns search results separated for each post type, however I would like to have a unique heading for each section and style it, currently it ...
Juninho10's user avatar
0 votes
0 answers
9 views

Add static image block to lastest list item

i use ACF repater: <div class="family__list"> <?php if( have_rows('list_family') ): ?> <?php while( ...
Lerry's user avatar
  • 111
0 votes
1 answer
208 views

Query Loop Block: possible to restrict just child pages?

Is it possible to use the Gutenberg Query Loop block to restrict the output to just the page's children pages? Or is it necessary to alter the theme?
Marc P's user avatar
  • 513
0 votes
1 answer
196 views

Saving meta box data from selected option's value in database is not working

I have added a organizer input filed using "select and option" tag, screenshot - https://prnt.sc/DtiJr5W178_g Here is my full code - // Callback function for Metabox <?php function ...
Moon Akondo's user avatar
0 votes
0 answers
48 views

How to set and retrieve cookies while in the loop

While inside the loop, I need to do some calculations with latitudes and longitudes to create a delivery fee based on a distance for each post. I have a couple hundred posts, but will only have about ...
Eric Wenger's user avatar
0 votes
0 answers
33 views

Create a WordPress loop that shows posts from a custom post type + filters the posts by taxonomies while hiding empty taxonomies

I am working on a page template for a custom post type where I need to only show posts that are tagged for a certain sport in a custom taxonomy. I am also displaying all posts that are tagged to that ...
Ashley Stanley's user avatar
0 votes
0 answers
194 views

Pagination only showed when no category is set in wp_query

tldr: On my production site only, when I set category_name to any category my pagination does not show up. Once I remove category_name from my wp_query the pagination shows up (for all posts on my ...
james's user avatar
  • 135
0 votes
0 answers
41 views

Wordpress post objects in one parent post object

I'm creating an event page where we can add an event line-up. Such a line-up consists out of different speakers. So I've create two custom post types: Line-up Speaker On my event page you can select ...
Dennis's user avatar
  • 135
0 votes
0 answers
90 views

Use Base-URL with Query-Loop

I've set the Base-URL for my WordPress page with <base href="https://www.example.com/" /> function custom_header_metadata() { ?> <base href="<?php echo ...
Marzii's user avatar
  • 1

1
2 3 4 5
67