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
2answers
17 views

Get posts that do not have the same tags as current

I'm trying to get all posts in a custom plugin loop that DO NOT share the same tag as the current one. I'm trying: $events = tribe_get_events([ 'start_date' => 'now', 'eventDisplay' =&...
0
votes
0answers
25 views

How to add custom checkboxes from loop to WooCommerce product variation options?

I want to make a custom checkboxes in WooCommerce product variation. How to save checked checkboxes in website to use it later? After this i want to display prodcuts depends on this checkboxes. ...
0
votes
1answer
36 views

Count products with custom metadata field in an order

I have a wordpress plugin which performs a count of purchased products in an order which are flagged with my custom metadata value. The custom metadata value is in the form of a checkbox within the ...
0
votes
0answers
24 views

Shortcode for Comments and Comment Boxes in Post Loop

Is it possible to get the comments and comment boxes for each post in a loop so users do not have to navigate to the actual single post page to leave a comment (and instead users can leave comments on ...
0
votes
0answers
35 views

WP query meta key is returning an array, how can I compare this to a date? [closed]

I'm using the ACF Multi Dates Field plugin with ACF to allow user to select multiple dates for an event. I need to compare the return value of the multi date plugin to the current days date. But the ...
0
votes
1answer
13 views

How to declare a variable in a loop and make it available in the template file

I was faced with a minor issue but can't solve it myself. I need to add the value on the variable after all loop iterations. And nothing problem, but I need to use this variable in the other file. for ...
0
votes
0answers
20 views

How to download data for each form separately with javascript and store each of it [closed]

I have many forms on the site (for each post separately). Now I would like to get the data from each form separately and get it for each one. So if I click a button in forms A, B, C, I would like to ...
0
votes
1answer
16 views

Limited adding only one product with more variations at cart [closed]

I would like to limited users from adding a second product at the cart. But he has the ability to add more variations of the first product. I he add a t-shirt with variation red he can only add t-...
0
votes
1answer
26 views

Get a Post Loop based on Logged in User information into a Shortcode

I have a follower button on users profiles where users can follow other users. I have a page template that shows all posts by users the currently logged in user follows. I would like to create a ...
0
votes
2answers
29 views

the_date() and the_time() functions display actual date an time instead of published date and time

It's really hilarious but my the_date() and the_time() functions show the current date and time instead of the post's publication time, therefore at each refresh of the page, the time changes ...
0
votes
1answer
41 views

Exclude a specific post in a Custom Post Type

I have a very simple query to display all my posts in a custom post type: <?php $page = get_page_by_title('Duck'); $args = array( 'post_type' => 'sessions', 'post__not_in'...
0
votes
0answers
13 views

Products listing check if meta checkbox is checked

I've created ajax filter for products categories and classic archive product page where is listed all products. I've created Is new product option checkbox for products. But I have problem that every ...
0
votes
1answer
22 views

Pagination contents not changing in Front page WordPress

This question has asked many time before and none has answers my question. I went through most of the answers before post this. I have a pagination query in home page. Pagination is showing and I can ...
0
votes
1answer
26 views

How to use custom page for all posts with custom url, call another directory?

I have tried many different codes: <a href="<?php echo get_template_part( 'template/test/post' ); ?>"> Test 1</a> <a href="<?php echo ...
1
vote
0answers
50 views

I write simple wordpress loop for taxonomy.php file but don't show result

I created a custom post type and create for CPT a taxonomy. but when I click on view taxonomy link don't work archive loop. I created taxonomy.php file for show this taxonomy in this file but display ...
0
votes
1answer
23 views

View post with specific category id and name which I selected in the backend (drop-down option)

I'm trying to get the category ID from Kirki Function and then pass the ID into a loop to get View all posts from that specific category id with name. I write this code at the backend: Kirki::...
1
vote
0answers
17 views

Custom Tag Description unable to display just below and outside of the Loop

Hello StackExchange Team! In my wordpress tags for custom post type, the code <?php echo term_description();?> or outputs fine just outside and above the loop. The problem I am having is that ...
0
votes
1answer
38 views

How to read taxonomy in loop?

How to read taxonomy in loop? Here is the code to explain better: <?php $term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $query = new WP_Query(array( '...
0
votes
1answer
27 views

wordpress custom fields loop

I need to do wordpress custom fields loop: here is the code to describe better: <?php $term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $query = new WP_Query(...
0
votes
0answers
15 views

Set depth of pages to fetch

I have a custom loop to display the children pages of a parent which works well - however, I want to be able to limit the depth of the pages to display. I only want 1 level of pages to be displayed, ...
0
votes
0answers
16 views

ACF: display custom filed of CPT into the loop

I have a CPT called Project (Projects in plural) and I am displaying it in the loop into a column. I would like to display a custom field I have into this CPT (called "type") underneath the ...
0
votes
1answer
44 views

Extracting relevant tags associated with that particular single post only

$tags = get_tags(array( 'hide_empty' => false )); echo '<ul>'; foreach ($tags as $tag) { echo '<li>' . $tag->name . '</li>'; } echo '</ul>'; The ...
0
votes
0answers
20 views

How To Noindex Specific Urls On WooCommerce

I am trying to set noindex meta tag when the url have inside the ?f=sale or ?f=colour. example url: domain.com/dress/?f=_sale%5Bsale%5D domain.com/dress/?f=colour%5Baquamarine%5D%7C_sale%5Bsale%5D ...
0
votes
1answer
25 views

Can't filter out variable products in sale from wp_get_products loop (or shortcode) [closed]

I'm trying to filter out all products in sale from a WooCommerce loop. So the goal is to create a loop of products that are new, but doesn't contain sale products. The problem is that the products are ...
0
votes
1answer
11 views

Trying to get all links in my posts

I am trying to return all the links inside my posts'/pages' content, but I can't figure out how to get my regex/loop to work right. Here is what I have at the moment, that just returns a bunch of ...
0
votes
1answer
12 views

Having Issue on Ordering CPT by Custom Field In Custom WP Query

Having a Custom Post Type loop like this, I am able to return the result on page BUT I am not able to set Order By of display using my own Custom Field. As you can see here $topic_number = ...
0
votes
0answers
39 views

How to show the rating stars of of woo commerce product through custom loop?

I would like to display product ratings for my woocommerce store on my home-page.php template. I put together the code below to display the product ratings but it only shows the admin and comment, I'...
0
votes
0answers
19 views

How do I implement an on-the-fly playlist of audio posts?

My blog consists exclusively of audio posts, made of: title, short description, WP audio element, a few tags. As usual, when a user clicks a tag, he's presented with a page listing all relevant posts. ...
0
votes
1answer
31 views

Custom post type loops with different page templates

My website has two different page templates. Each page template contains a different custom post type. The posts from the loops can be loaded by AJAX to load more. This is the common code that I run ...
0
votes
0answers
12 views

Finding the best results using a range of values

I'm currently working on a health and fitness website where a user inputs their daily calories and macro nutrients information (carbs, fat and protein). I have thousands of food items with custom meta ...
0
votes
2answers
81 views

Custom wp_query inside a conditional stament inside a template part doesn't work: why?

this is a bit messy and I cannot understand why my approach isn't working or what my error is. I'm using a template part to include a custom wp_query into my theme. I'd like to have two different ...
0
votes
3answers
49 views

Display articles with a different template in the home page | Solved |

I am creating a theme for my site. I would like to display the last 5 articles on the home page but with a different display for the first articles. So I created this code that I try to tweak but ...
0
votes
0answers
21 views

Loop keeps showing the same post even when I click on a different one

So I am trying to build slider loop that shows posts related to a series, it seems to load the same post no matter what post I click on. I am using wp post format to differentiate posts between video, ...
0
votes
1answer
26 views

display ACF repater field in archive page

I created ACF repeater field for custom taxonomy terms. Repeater consist of two field "Question" and "Answer" . By this way I want to create FAQ section for each taxonomy term. ...
0
votes
1answer
13 views

in_array not working on dev server but works on localhost

I've written a loop which works on my local machine but not on my dev server. My dev server is running PHP 7.4.13 and my MAMPRO is running 7.4.12. The dev server code displays nothing and with no ...
0
votes
0answers
33 views

Custom post type paging return home page

I am having problem with Custom post type paging. Clicking on 2nd page of paging through back to home page. Permalinks flush/refreshed and i am using simple code to show custom post. following is my ...
0
votes
0answers
21 views

Custom Post Type loop including pages

I created a loop for my Custom Post Type event. I would like also to include in this loop some extra pages by ID for example. Is it possible to do it? The code for my loop: <?php ...
0
votes
0answers
13 views

Display related products by matching the product title to any tags of the current article

How do I display products in a custom post type single page by matching the queried product title to any tags of the current article? Below is my code which seems to output some random product names, ...
0
votes
0answers
42 views

Pin posts to top of custom loop

Question What would be the best way to pin certain posts to the beginning of a custom loop that queries for many custom post types and may or may not have tax queries inside? Due to how the rest of ...
-1
votes
1answer
25 views

When and how will php code in a user made Wordpress page be executed?

What I have understood about what's happening when a web page in a Wordpress built web site is loaded is that Wordpress determines which post (page) and which template for that page to load. It then ...
0
votes
1answer
17 views

Permalink Short code showing unnecessary link text inside the loop

Recently I need Help regarding this permalink shortcode function my_permalink(){ ob_start(); the_permalink(); return ob_get_flush();} add_shortcode('my_permalink','my_permalink'); for this, I get a ...
0
votes
0answers
27 views

Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron

I'm working on calling my function from server cron instead of using WP Cron. The problem I occured is simple. When I add $args to wp_schedule_event() method, and check for the successfull addition in ...
0
votes
1answer
20 views

$post is undefined in wordpress loop [ajax]

I'm currently working on calling the next page of posts through ajax. I'm making my request with jQuery, building a custom query in my php handler function, looping through it and then sending back ...
0
votes
0answers
22 views

Query users and count totals based on meta values

Users can choose a value from a multiple choice checkbox on sign up. In this example the choices are Cat or Dog. I have a WP User Query and want to count the amount of users that have each meta value, ...
0
votes
1answer
21 views

posts archive page - closing WP_Query loop correctly [closed]

I am trying to use an example of the loop shown in this post Output yearly archive within a page to output post links grouped by year page-archive.php <?php /** * Template for displaying archive ...
0
votes
0answers
23 views

How to add pagination in Terms

Hello on my website I have created a page where it will show all of the Woo Commerce tags in the store in list format. The problem here is that I am unable to paginate them. I have tried ...
0
votes
1answer
84 views

Pagination not working on custom query on a page

I have a custom query on a page (it is not an archive page), it works just fine, but I want pagination and it is not working at all... <?php $paged = (get_query_var('...
0
votes
1answer
22 views

Make loop inside slider divisible [closed]

I'm trying to divide a posts loop in order to show 4 posts per each slide inside a slider. The code below works good, but since the number of posts in the Wordpress panel is dynamic and varies, it ...
1
vote
0answers
23 views

Taxonomy name repeating when showing 2 posts from each category

I am trying to get my page to show a custom taxonomy and then a the first 2 posts in that taxonomy, My taxonomy is called types post type is called guides I want the page so it shows like this Type 1 ...
0
votes
1answer
27 views

Display a single category in blog section

I have been struggling with a problem, I have a webpage running on WordPress, most of the things work as expected, except one: in the blog section page (the one that is configured in settings/reading -...

1
2 3 4 5
65