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
19 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
7 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
20 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
21 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
15 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
22 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
18 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
17 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
19 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
20 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
57 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
20 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
21 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
24 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 -...
0
votes
1answer
13 views

Loop through posts of only 2 statuses

Setting up a visibility condition for a widget - i need it to apply to the posts in a certain term but only those of "pending" and "publish" status. this essentially hides the &...
0
votes
0answers
16 views

How can I order all subcategories alphabetical independent of the parent categories?

These are my hierarchical three level categories: - Top-Level Cat 1 - Sub1A - Subchild1A1 - Subchild1A2 - Sub1B - Subchild1B1 - Subchild1B2 - Top-Level Cat 2 - Sub2A - ...
0
votes
1answer
54 views

Make bootstrap 5.0 carousel dynamic using ACF and CPT UI [closed]

I am trying to make bootstrap 5.0 carousel (with indicators) dynamic using ACF and CPT UI. I realized that I need to display the number in data-bs-slide-to dynamically, as well as other numbers and ...
0
votes
0answers
51 views

How to get specific (grand parent) category of current post?

I am having a category hierarchy with three levels. My example: - Top-Level Cat 1 - Sub1A - Subchild1A1 - Subchild1A2 - Sub1B - Subchild1B1 - Subchild1B2 - Top-Level Cat 2 - ...
0
votes
1answer
20 views

How to add a shortcode function that returns the taxonomy slug of the actual post within the loop

Circumstances: I have a CPT called "designs" and a taxonomy related to it, called "project_category" so that I can assign a category to each design. I'm building the template for ...
0
votes
0answers
44 views

How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?

I am trying to Create Carousel Slider in which Images get from the wp_get_attachment_image_url function and all other alt title and caption data it works correctly. I am stuck at carousel Indicators I ...
0
votes
1answer
43 views

Show ACF field with link to ultimate member profile/Wordpress user profile below the post (single post layout)

I'm using Advanced Custom Fields and I'm trying to show a custom field below the single post. I managed to get the code to render below the post, but when I set the field movie_actors and save, the ...
0
votes
0answers
15 views

How to output the taxonomies that are assigned to each custom post?

I'm trying to loop through all custom posts and output the taxonomies that are assigned to each post. The code below is currently just outputting every taxonomy available to the post, even if it isn't ...
0
votes
0answers
20 views

Woocommerce / Product Columns on Shop Loop / Responsive

I'm trying to make the following layout 1 Column / Mobile 2 Column / Tab 3 Column / Desktop I have set up the customizer so that there are two rows, and three columns. This works on desktop, and I can ...
0
votes
1answer
32 views

Add function after the_content

I have the following function within a simple plugin: <?php /** * Social buttons */ function zss_social_buttons() { ?> <div class="zss"> <!-- Facebook --> ...
0
votes
1answer
21 views

Populate select list with meta values from all posts of a Custom Post Type

I've got a CPT of Inventory and I'm trying to show a dropdown of all Mfrs. I've got the form and pre_get_posts function so that when a user selects a Mfr, the page refreshes and shows only the ...
0
votes
0answers
11 views

Posts number in a loop that uses term and date

Im using this method to get some posts with a certain term in front of others. But, as Im also using pagination, term-a posts are being divided between all pages, so sometimes the number of term-a ...
0
votes
1answer
15 views

Why does my loop breaks the css below?

<?php /** * My Orders - Deprecated * * @deprecated 2.6.0 this template file is no longer used. My Account ...
0
votes
0answers
22 views

How can I count the clicks on a button in a post loop list?

This script is fine to count clicks on any button by id or class in a single post type template to save the counts into a custom field. But I want to count the clicks in the loop post list in the blog ...
0
votes
0answers
31 views

Prevent Duplicate Post Counted by Query

<?php while ( have_posts() ) : the_post(); $get_series_id = get_post_meta( get_the_ID(), 'series_seri', true ); if (in_array($get_series_id, $do_not_duplicate)) { ...
0
votes
0answers
21 views

How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?

The Setup I have divided my blog into 3 categories with their respective slugs. There are 3 pages corresponding to these 3 categories with their respective custom page templates. On each page, I ...
0
votes
0answers
9 views

Portfolio items created indefinitely from external API. Every time different number

I am trying to make new portfolio item for every json item from external api. I am working on Wordpress and placed my code in functions.php of the theme used. When i run my code, it creates portfolio ...
0
votes
0answers
15 views

Advanced Custom Fields “Flexible Content” to not echo header if layout is unused

My website allows front-end users to create posts, they can add quotes, highlights and sources for their content. I am using Advanced Custom Fields "Flexible Content" for the user to add as ...
0
votes
1answer
35 views

Hover a css icon width other color inside wp_get_attachment_image

I'm using ACF and have inside a loop: <?php echo wp_get_attachment_image( $button_image, 'small', 'sidebar-btn-icon', ["class" => "sidebar-btn-icon" , "alt"=> &...
1
vote
1answer
15 views

Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?

I currently have a Portfolio custom page in Wordpress, so far work as i want, but i have one problem. The problem is when i click one of the button slug then the body/output is not work like i want, ...
0
votes
1answer
11 views

Tags on page (not post) returns nothing - why? Improved clarified question!

Problem: I'm trying to echo tags to list items but only manage to echo the "else statement". Since this is about tags for pages I have added support for pages to show tags in functions.php: ...
0
votes
0answers
16 views

How to display all posts in a category at the end of a single post?

The "work" page for my portfolio is simply all the posts in the "work" category. They are displayed as a thumbnail grid. Here. <?php get_header(); ?> <div class="...
0
votes
2answers
34 views

Wordpress query undefined offset in loop

I created a query with arguments see blow. On the page I see an error in a loop Notice undefined offset 1 Notice undefined offset 2 Notice undefined offset 3 and so on... $args = array ( '...
0
votes
0answers
239 views

Generate multiple pages pdf with AJAX using mPDF library

I am developing a plugin that generates various PDFs using AJAX. I have done all but stuck on generating multiple PDFs for each user using the loop. I prefer to generate PDF with multiple pages for ...
1
vote
0answers
25 views

Limit the number of acf content when displaying in post loop [closed]

I display post images by this way in the loop . <?php $images = get_field('POST-IMAGES'); $size = 'medium'; // (thumbnail, medium, large, full or custom size) if( $images ): ?> <ul> ...
0
votes
0answers
18 views

Confused. How to remove WP_Query $args from AJAX posts loop and make it work?

I am currently working on a custom theme project where I am trying to make AJAX load more function work for custom-post-type, 'product' I just made. I went through a tutorial on internet and got the ...
0
votes
0answers
11 views

Show products from the same sub category

I'm trying to write a wp_query in my template of a woocommerce product to display a carousel of some related products from the same sub category of the product I'm seeing. My code is like this <...
0
votes
0answers
20 views

How to make toggle content from custom posts

I'm looking a way to toggle some content from custom post type. ex : https://vignerons-cairanne.com/fr/vignerons-cairanne/ I wan't something similar, when you click an image, it display the content ...
0
votes
0answers
10 views

index page shows loop of all posts, I want to change it into loop of 'exhibitions' category

Index page shows loop of all posts, I want to change it into loop of 'exhibitions' category my website is on my localhost but I am using this wp theme http://expositio.wpshower.com i don't know php ...
0
votes
1answer
25 views

wp_get_attachment_url not fetching URL?

the below code does not seem to return an image url at all, chrome inspector says source is unknown foreach ($subcategories as $subcategory) { $link = get_term_link( $subcategory->...
1
vote
1answer
27 views

Exclude category from

I am trying to exclude a category from <?php the_category(', ') ?> inside my loop. I came across the following code on CSS tricks that says would solve the problem. You add this to the functions:...
0
votes
1answer
20 views

Duplicated <a> tag in loop

I stuck on this issues, looks simple but can't find resolution to fix it. I have such loop: <div class="features-items__wrapper"> <h2><?php echo $currentTitle; ...
0
votes
1answer
13 views

Pagination not working in custom post type. Help

I am currently working on an eCommerce project where I am coding a non-WooCommerce dependent theme for eCommerce. The current problem with me is, I am coding archive-product.php which is a custom post ...
0
votes
1answer
41 views

Change date format

I am using wordpress for an integration with an recruitment software. Now i am having an issue with an 'endDate' slug. The date format seems to show up as yyyy-mm-dd. How can i change this format to ...
0
votes
0answers
71 views

Duplice post with standard WP loop - fixed by using query_posts() instead

I have an index.php file on a website designated as the blog page. I have an archive.php file which handles all the subsequent category pages. I ran into an issue on the archive page, where for one of ...
1
vote
1answer
24 views

Use object in template part

I try to use a template part in my loop. <?php foreach ($categories as $category) { get_template_part( 'temp-parts/loop/blcnr_loop'); } ?> In the template part I call the object <?php ...

1
2 3 4 5
64