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
1answer
10 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 &...
4
votes
1answer
1k views

Custom Loop and Infinite Scroll

I am using customized version of _s theme where I have Product CPT. In the following files, I need to use Infinite scroll (provided by Jetpack) - archive-products.php taxonomy-[tax-name].php ...
1
vote
1answer
2k views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
0
votes
2answers
88 views

Way of getting queried loop before the query with a filter hook?

Is there a way to get the results of a loop with a filter before the code for the loop is performed in the structure of your code? My markup is something like this: <body> <div> /* ...
4
votes
1answer
5k views

AJAX handler throws 400 (Bad request) - why?

I am trying to apply a "Load more posts" function to a post loop, but I am dealing with a 400 Bad request, when admin-ajax.php is referred to. The reference I used is this - https://rudrastyh.com/...
0
votes
1answer
952 views

Can't add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS

I can't add new plugins or themes on a wordpress multisite network from the primary site as super administrator. It shows this error: ERR_TOO_MANY_REDIRECTS. However, I am able to access all pages, ...
9
votes
1answer
9k views

AJAX with loop filtering categories

I've been researching on how to make my loop with AJAX. I found some codes online and modified some parts but I can't seem to get it to work. This is my code for the loop: <article id="main" ...
-2
votes
0answers
10 views

Injecting posts within a woocommerce product loop

I am working on a woocommerce site and I am trying to figure out how to inject specific category posts in between the product page loop(woocommerce_product_loop). Similar to this: X Y X X X X Y X X X ...
0
votes
1answer
43 views

Make bootstrap 5.0 carousel dynamic using ACF and CPT UI

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
15 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
0answers
50 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
2k views

Deeply Nested Menu Loop with Twig using Timber

Using TimberMenu() and I have a menu for mobile that needs to go pretty deep. There must be a better way to write this with twig. Using macros and/or loop.parent or loop.index? It's basically this ...
0
votes
0answers
25 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
1k views

Custom post type archive pagination with HTML5Blank theme?

Can't get the pagination to work. Here's my archive-work.php: <?php get_header(); ?> <main role="main"> <!-- section --> <section> <h1>&...
0
votes
1answer
16 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 ...
1
vote
1answer
603 views

Excluding pages in WP_query using ACF

I have a custom loop for showing child pages of the current page, but I'd like to allow the WP user to enter page IDs to be excluded from the loop, using Advanced Custom Fields. My current loop is as ...
0
votes
1answer
31 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 ...
1
vote
2answers
3k views

Two loops on archive page

I have 2 loops on the archive page. I want the first loop to display the 2 last posts of the category and the second loop offset 2 last post! <div class="top-posts"> <?php if (...
0
votes
1answer
911 views

Query to get child pages of current page and display it in action hook

First I want to apologize if there are spelling mistakes in this question. I'm using Genesis Framework. According to the following answer: https://wordpress.stackexchange.com/a/60295/146574 I'm ...
0
votes
0answers
19 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
2k views

Pagination in custom post type page template

I made a query for my custom post type "websites". I'm trying to get the pagination working but I'm running in some errors. I think the whole code is ok, only the part just before the end while tags. ...
0
votes
1answer
31 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
2k views

Add active class to foundation 6 tabs while looping categories

I have a custom post type (bulletins) that I'm putting into Foundation 6.4.3's tabs and accordions. The taxonomies are the tab headings. The individual custom post type content is the accordions. My ...
0
votes
1answer
13 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 ...
1
vote
1answer
543 views

Alter query using pre_get_posts() if meta_key is present

I am trying to modify the number of posts per page for archive pages that contain category sticky posts (added by the Category Sticky post plugin) to do so I am using the pre_get_postshook and have ...
2
votes
1answer
562 views

Double count view in archive.php

I'm having a hard time using this snippet I'm getting double views each time the post is queried. This is in my functions.php file: function getPostViews($postID){ $count_key = 'post_views_count';...
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
14 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 ...
1
vote
1answer
658 views

Using an ACF field from a page within a post loop?

I have a page set up with custom fields using Advanced Custom Fields. One of the fields is a text field for specifying the text for a read more button. Within the page template I have a post query to ...
0
votes
0answers
20 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
1answer
560 views

Pagination on custom post types

Pagination works in the front page but in custom post type page it doesn't appear. Post type: add_action('init', 'portfolio_register'); function portfolio_register() { $args = array( ...
1
vote
1answer
768 views

pre_get_posts for two loops on same page

I'm using two loops on homepage, one is to show the 3 latest posts, and the other one to show the rest of the posts minus the 3 first posts. I'm using the following code for the pre_get_posts. ...
0
votes
0answers
29 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)) { ...
7
votes
3answers
35k views

Loop within a loop?

I'm using a couple of custom wp_query loops on my page, the first one retrieves news from a certain category then displays a small excerpt from it with the permalink. The second one is another ...
0
votes
2answers
4k views

Troubleshooting “loopback requests that take too long”

So I am dealing with this dreaded "unable to edit php files" errors after updating to 4.9.1 I disabled all of my plugins, and I am still getting the following error though the Health Check plugin: ...
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
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
8 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
1answer
34 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"=> &...
0
votes
1answer
10 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: ...
1
vote
1answer
14 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
576 views

ACF page while loop breaks footer while loop

So basically i have a main page and a footer page. Both are seperate .php files. Im using ACF for this site. Following the documentation, ive created a while loop for my 'flexible content' in the ...
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="...
1
vote
2answers
884 views

WP Query with categories only shows one post and ignores the category

I'm trying to make the following mock up with WordPress: https://imgur.com/a/Sem7y I created a custom post type and I created two categories (general and filling instructions). I used ACF plugin to ...
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
78 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 ...
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 <...
1
vote
1answer
1k views

Ajax Infinite Scroll In Custom WP_Query Loop Not Working

I have set up a custom WP_Query loop for a page template. I am implementing an infinite scroll method via ajax, and the call is successful, but for some reason I cannot get the query to like the paged ...
1
vote
0answers
24 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> ...

1
2 3 4 5
64