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
0answers
12 views

WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination

Im struggling to find a good resource on implementing my own AJAX product pagination onto products within the WooCommerce shop loop. Please can someone guide me on how is best to load more products ...
0
votes
0answers
6 views

How to add image/Text from custom fields on Woocommerce product list in Shop Page or any other page where products are displayed from woocommerce

I tried to find any file to edit or create my custom theme template file for loop of products displayed but I didn't find anything for my custom theme, Please Help Me
0
votes
0answers
13 views

Display custom posts and their childs hierarchicaly

I am working on a support manual. I created a custom post type 'manual' and I want to display an automatic menu of the posts and their childs. It would look like this: Post 1 Post 2 Child post ...
0
votes
0answers
12 views

Send items with blank meta query values to bottom of the list

I have the following code which loops through some custom post types and orders them two custom meta values - firstly by start date and then secondly by duration. This works fine - except for tours ...
0
votes
2answers
25 views

How do I control the output of a custom post type in the loop?

I'm working on a new content type. Let's call it hotel rooms (it is not but the similarities are good enough). Now, for each room, I will have a title and a description but I will also have a lot of ...
0
votes
1answer
11 views

Add content after the first post in WP Loop

I want to display a list of categories after the first post in the Loop of index.php (this is the template my WP theme uses to display posts). I've searched around on the web and found some code (see ...
0
votes
0answers
10 views

Filtering get_terms loop by custom fields & custom taxonomy

On specific page I’m displaying posts from my CPT („opencourses”). Posts from this specific CPT are grouped by custom taxonomy („kategoria”) - this piece of code works. At the same page I have four ...
0
votes
1answer
23 views

Custom query for certain post type OR another post type with a certain category

I want to display posts that are either EITHER Post Type A OR Post Type B but ONLY if they are also in CATEGORY 1 Is that at all posible? How do I built my custom query?
0
votes
1answer
19 views

Display the last post by each category?

How I can display the last post by each category? Point is to display the last post on the page for all categories, I need to show them in front as normal <ul><li> list. Any idea? ...
0
votes
1answer
21 views

Custom Loop.php having a loop inside a loop

Need some guidance. I am creating a custom grid for a blog. So for example block 3 and 5 are bigger etc... But for this to happen after else: i need to have two blogs in that one area so will be two ...
0
votes
1answer
22 views

display post format text in loop

If post format is Gallery or another then echo my custom text. Get post format from post id. I want to do like this code in wordpress post loop if (isset(get_post_format(gallery))){ echo 'Gallery'; } ...
0
votes
0answers
14 views

Get categories within specific term

I have a WooCommerce shop, where I'd like to show every possible product category, where the products have a specific attribute (term). Say I have a product attribute called: "Designer", then I wish ...
1
vote
1answer
22 views

Display CPT posts based on specific taxonomy

So I have a custom post type called opencourses. There is a custom taxonomy called typ. Obviously inside I have a multiple terms divided into two main pillars (production and services). ...
1
vote
0answers
24 views

Iterate through posts based on array of categories

Is it possible to loop through posts based on an array of categories? I would like to loop through an array of categories and then display those posts based on the category they are a part of. Posts ...
1
vote
0answers
18 views

Group CPT posts by custom taxonomy

Being honest I've stucked with my code. So I have two things: - CPT called: opencourses - custom taxonomy called: typ currently I have a template which displays pure list of CPT posts. And it works. ...
1
vote
0answers
26 views

Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?

Short version: I am wondering if the default WP loop (for example in a rather simple index.php) is supposed to return custom posts belonging to a custom taxonomy when the URL is something like https://...
1
vote
0answers
24 views

Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?

I am trying to embed a custom WP_Query inside a shortcode I have activated on one of my pages (created in Elementor). I have a Custom Post Type called 'inspector-profiles', and for some reason when I ...
1
vote
1answer
18 views

Loop in Related Posts Wordpress

I use this script to display related posts: <!-- Related Posts START--> <?php $query = get_max_related_posts(); if ( $query ) { ?> <div class="td_block_wrap td_block_7 ...
0
votes
1answer
15 views

wp_query get the 2nd post

How could I get only the 2nd product in this query? $loop = new WP_Query( [ 'post_type' => 'product', 'posts_per_page' => 1, 'meta_key' => '...
0
votes
1answer
22 views

How to use single.php output in function.php

In single.php, inside the loop the code shows text output. <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> $content = ...
1
vote
1answer
24 views

How to use offset in WP_Query

Where do I put the offset function? <?php $args = array( 'post_type' => 'post', 'category_name' => 'category', 'orderby' =&...
0
votes
1answer
21 views

How to separate post titles with a comma in the loop?

How do I list all my posts with a comma (but not after the last post)... <?php // WP_Query arguments $args = array( 'post_type' => array( 'post' ), 'tax_query' => array(...
1
vote
1answer
33 views

How can marge these loop code?

I just need an idea where to put this code: $term_featured_image_id = get_term_meta( $custom_term->ID, 'wp_travel_trip_type_image_id', true ); $image_url = wp_get_attachment_url( $...
1
vote
0answers
10 views

Conditional query that displays on Woo product attribute pages

I have a custom query set up that currently modifies the product category pages of my website. I would also want this code to affect the product attribute archive pages of my website, but I am having ...
0
votes
0answers
17 views

Gutenberg Blocks Messes Up Layout?

So we designed a page that includes a section where featured news articles are displayed. The most recent article is displayed on the left side, while the other recent articles are displayed on the ...
0
votes
0answers
18 views

Custom Query with Sticky Posts

I’m trying to write a custom query which filters by category and shows only a certain number of posts. So far that’s a simple thing along these lines: $args = array( 'showposts' => 1, 'cat' =>...
0
votes
0answers
15 views

Display post taxonomy based off custom metabox selection

I am using CMB2 to display a custom taxonomy which is calling the categories from my post and displaying the results within the page backend in a select field. Each page will have the ability to ...
0
votes
1answer
18 views

How to loop custom posts that have an exact match in taxonomy terms?

I have created a loop to display programs. One of the taxonomies for each program is a grade or grades. Some programs are for 1st and 2nd graders, for example. I would like to display a div in my ...
0
votes
2answers
78 views

Distribute Gallery Images Every nth in Loop

I have added an acf image gallery for archive terms and I would like to take those images and insert one image from the gallery every 3 posts in the term archive. This is what I have so far but I am ...
0
votes
1answer
24 views

ACF - Get ID of relationship field in flexible content

I'm trying to get ID from a relationship field within a flexible content and push it in a array if (have_rows('studio_blocs')) { while(have_rows('studio_blocs')) { the_row(); $...
0
votes
0answers
29 views

New posts not visible

I've a website. It was initially developed by a different developer. It has custom template work done to it. In the wp-admin "projects" can be seen in the menu. When I click all projects, all ...
0
votes
0answers
23 views

Loop through an iteration of 500 results at a time and increment page and restart with next 500

Below, I will explain all the steps and how everything works so you get a better understanding of what I'm trying to achieve. The import_employees function kicks off and grabs the $settings['page'] = ...
0
votes
1answer
29 views

Add Search and Filter functionality to custom loop

I have a custom post type and a page where I loop through them. I'm trying to implement the plugin Search and Filter to the page, so people can filter the custom posts. However, it does not work at ...
0
votes
0answers
17 views

Loop through and output more than 500 results

I have the following code and below I will explain what all I receive and what the output results too: function import_employees() { $log = []; $name = 'octopus_import_employees'; $...
0
votes
1answer
49 views

Should I reset $wp_query?

I am not totally new on WordPress but the query thing is a bit confusing to me. I searched the web and read a lot of articles, but I couldn't find what I needed. Maybe it could help a lot of people ...
0
votes
1answer
56 views

cURL needing to loop through all “next_page”

When using cURL, how would I be able to include a call inside my get_all that basically will loop through all the next_pages, get the data and then outpul it to $response->data when the "next_page" ...
0
votes
0answers
20 views

Multiple post in One Loop in wordpress

I’m converting HTML website to wordpress dynamic and having trouble getting duplicate posts. Code is following kindly please guide me in this regard m new with wordpress and PHP. <div class="...
0
votes
0answers
25 views

Is it possible to have 2 Args with pre_get_posts?

Is it possible to use the pre_get_posts hook using two sets of args? For example, if I want to modify my main loop to first display all products that have a tag sponsored and then display all the ...
0
votes
1answer
26 views

Show articles in Pair

I'm looking at displaying articles in twos. ie: <section class="side" data-role="side" id="section-section1"> Two articles </section> <section class="side" data-role="side" id="...
0
votes
0answers
9 views

Post loop inside current post - is this approach valid for avoiding pitfalls?

I have a post type called lesson that contains various topics. A topic has its own route and when a topic template is loaded it sets the post to be the given topic post. The thing is, I want to ...
0
votes
0answers
17 views

Static position inside an ajax-called loop

0 I am serving an output of five posts in my homepage and upon scroll down, I use an Ajax call to implement a load-more functionality, which loads a next series of 5 posts. So, upon scroll down, $...
0
votes
1answer
131 views

Loop in elementor custom widget not working

I have a custom made widget for elementor, but my problem is that my loop to get posts doesn't work properly. Currently, it returns the title of the page where the widget was inserted, doesn't show ...
0
votes
0answers
28 views

Display specific posts based on an ID of another post

I'm trying to display specific posts based on an ID of a post. I got it working with 2 posts and I will get it working for the 10 posts that I need it for, but it's going to be a lot of code and I ...
0
votes
1answer
22 views

Loop with custom posts, to include information from different custom post type

I currently have a loop to display custom posts for courses. Now I also have a custom post type for universities. Both have a certain 'schoolID', so I can link the courses to the university. Now I ...
0
votes
0answers
22 views

how to add 4 post in one carousel slide

I want to display 8 posts in twoeach carousel slides, that mean 4 post in each slide. i'm using a loop to display post but the problem is, it is showing one post in one slide and hence displaying 8 ...
0
votes
1answer
37 views

Avoid removing duplicate posts

I have an arrays of IDs which may contain duplicate values. Array ( [0] => 24 [1] => 11 [2] => 60 [3] => 11 ) I'd like to loop through those IDs using WP Query and the ...
0
votes
0answers
14 views

woocommerce product listing issue with owl-slider

I am using WooCommerce shortcode : [product_category category="course"] for listing my products. I wanted the list to be inside a slider (owl carousel - https://owlcarousel2.github.io/OwlCarousel2/) . ...
0
votes
0answers
14 views

SEARCH QUERIES - REVERSE OUTPUT

When I perform a search on the WP admin side for my custom post query I am returned with the most relevant queries first. Great However, performing the same search on the front end of the site and I ...
0
votes
2answers
29 views

How to show only specific tag in wordpress loop

I am trying to get the loop to show only two tag that have the ID 53 and 52. the code without the "if is_tag( array( 53, 52 ) ){" works. I tried different thing but I can't get it to work. Thank you ...
0
votes
1answer
37 views

Avoid showing the same phrase in the loops

I use this multiple loops to show the sold of some wears, so if there are the sold (meta_value=yes) the txt or presentation must be showing one time in top, and others products in bottom, and if the (...