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
1 answer
11 views

Add leading zero to current post display [closed]

I am using the next to show in a loop of posts the current post and the total of posts published. $post_query = new WP_Query($args); $postAmount = wp_count_posts( 'post' )->publish; <?php echo ...
user avatar
  • 19
1 vote
1 answer
28 views

Filter post by current 2 differents users id

I'm filtering my custom post type based on author. I want all users to be able to: 1 - in the list everyone can see the posts created by the admin. 2 - users can also see their own posts in the list, ...
user avatar
0 votes
1 answer
9 views

ACF to select posts not displaying on blog page

I am trying to implement a repeater / post object so I can select posts that I want to displaying on the sidebar. I am using this code: <?php while ( have_rows('top_posts_repeater')) : the_row(); /...
user avatar
0 votes
1 answer
29 views

For each loop on every word in post

I'm having a recipe site where every post naturally contains ingredients. Every ingredient is a tag, and I would like to automatically link every ingredient so the user can click on it and see all ...
user avatar
0 votes
1 answer
25 views

Dynamically insert code to custom post type loop

I need to display post from custom post type name "film", from a specific taxonomy "Horror." Everything work fine when I type the taxonomy directly like this: <?php $blog = ...
user avatar
0 votes
0 answers
12 views

Sort posts according to a numeric value entered with ACF

I've tried a little bit of everything, but I still can't find the right solution. I need to sort my posts according to a numeric value that is entered in each post. I'm using the following PHP code, ...
user avatar
0 votes
0 answers
18 views

How to loop specific Category menu from archive page?

I'm trying to loop a specific product category menu from the archive.php page and the category has 4 columns or as a 4th Tree How I can Loop it here in ul ? <ul><!-- 1--> <li&...
user avatar
0 votes
0 answers
15 views

Custom Header added within Dashboard pages, is this possible with custom template files?

I created a custom template and called it Header Home"header-home.php" <?php /** * Template Name: Header Home */ ?> <?php if( have_post() ) { while( have_post() ){ ...
user avatar
0 votes
1 answer
25 views

Custom Fields - How to create a list from multi-line entries of a single value

If I have the following name/value pair for a custom field.... ...is there a PHP loop process I can apply that will allow me to display them on the front-end as individual values because there is a ...
user avatar
  • 708
0 votes
1 answer
22 views

Category post count is not correct

When I go to Posts > Categories, some categories show that they have a post. See screenshot. But there are no posts linked to that category. When you click on that "1"-number, no posts ...
user avatar
  • 125
0 votes
0 answers
15 views

Display all categories but only if they have posts in them that have a specific tag assigned

I have a WooCommerce site and am working on the product tag pages. I want to display every product that is assigned to that tag, and break them up into their individual categories (this bit is working)...
user avatar
0 votes
0 answers
12 views

Woocommerce Variable Product Dropdown for Custom Shop Template

I'm building out a custom shop template and I'm trying to achieve something like this. Where the user can choose the product variation in the dropdown, choose quantity, and click add to cart without ...
user avatar
0 votes
0 answers
15 views

Get Posts List of Current Selected Custom Taxonomy in Shortcode

I have a custom taxonomy called Album Link (album_link). I created this so I could link all music that has the term e.g (Glorious Album) to an album post type that uses the same term. The goal here is ...
user avatar
1 vote
1 answer
32 views

WordPress Loop inside Loop?

I'm using ACF, and displaying the Brands CPT. Inside of brands, I will want to setup a separate loop for posts containing certain tags. My loop works, meaning that I'm able to access the brands and ...
user avatar
0 votes
1 answer
21 views

List page is showing 404

I have built a new site based on a content from an old one. Also, there is some partial content in another WordPress blog which I have to import. Unfortunately, on the blog I don't have full access, ...
user avatar
  • 101
0 votes
0 answers
20 views

What am I missing in this Code Block?

I am using ACF Pro and Oxygen Builder. I have a FG (Repeater) set for a Rooms & Suites FG. I have several sub_fields to capture attributes of each such hotel room that gets created via its CPT. ...
user avatar
0 votes
1 answer
17 views

Include current post into loop

I have a related posts loop ( in every single post page ) based on post title. source : https://wpza.net/get-related-posts-based-on-the-posts-content-in-wordpress/ But I also need to include current ...
user avatar
0 votes
0 answers
10 views

Page that lists publications by classifying them by taxonomy

I need a little help writing code. I have an "artists" CPT I have an archive-artists.php page with the code below, but I would need to add a "year" taxonomy. And that my artist ...
user avatar
0 votes
0 answers
12 views

How do I set the Stewart Search Template to return only published posts in the result

I recently took a WP.com online webinar and the moderator referred me here to ask my question. I am trying to redesign my site using FSE. I am using the "Stewart" theme. I have added a ...
user avatar
  • 1
-1 votes
1 answer
51 views

Use callback function in AJAX pure javascript [closed]

I've been looking for a while, but nothing answers my question. How can I turn this code in jQuery into pure javascript? I need it to work for the load more that loads other posts on my WordPress site....
user avatar
0 votes
1 answer
34 views

Custom archive page for custom taxonomy and pagination issue

so this is something I am trying to figure out for quite some time about my custom archive page for a custom taxonomy 'workplace'. There is many workplaces, and what i want is to display the products (...
user avatar
  • 16
0 votes
0 answers
34 views

Function the_posts_pagination() not compatible with WP_Query arguments

I trying to make a list with posts from specific category. It's supposed to work as the loop in category.php file. Unfortunately i have problem with pagination links which are completely not ...
user avatar
  • 145
0 votes
1 answer
13 views

Custom loop ordering not working

I have a custom loop to display the children of a parent page which works well - however, I cant get the ordering of the items to work as I want - I want them to appear in alphabetical order (A>Z). ...
user avatar
  • 3
0 votes
1 answer
51 views

Properly loop through and paginate page on each function call

Alright, I need some help and I don't know if I'm doing it the correct way, but I wanted to see if the community can guide me in a better direction. Here is what's going on: I have a ...
user avatar
  • 21
0 votes
1 answer
35 views

Add custom text automatically on each post

Suppose I have a post and it's the first paragraph is: "This a Pen. The color is red." I want to add a custom text like "2022" after "Pen" on first sentence, at the end ...
user avatar
1 vote
0 answers
17 views

Sort by alphabetical order archive.php page

<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?&...
user avatar
  • 11
0 votes
0 answers
13 views

Include last post date in get_categories loop

I have a simple get_categories loop on a template page which works fine to display a list of categories within the parent category 52 (as shown below). I would like to also display the last post date ...
user avatar
  • 1
1 vote
0 answers
31 views

Getting different functions data while using while loop in wordpress

I have added this code in the function.php file but when I use while loop in any other files this function is getting triggered. <?php add_action('loop_start', 'userlogin'); function userlogin() { ...
user avatar
  • 9
0 votes
0 answers
9 views

CPT loop doesn't seem to account for post date?

I have some custom post types called "products", all with different published dates. Below is my loop that grabs these posts: $args = array( 'post_type' => 'product', '...
user avatar
  • 101
1 vote
1 answer
14 views

Class active for Archive link - looped out

I want to have the current Archive page link to have the class "selected". So if I'm in /category/featured/ that button on the menu should have the class selected. After trying several ...
user avatar
  • 13
0 votes
0 answers
19 views

How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)

I have an ACF text field for a CPT that is holding a date in DD/MM/YYYY format (it's a text field and not a datepicker field as the data was imported from a CSV file). My Wordpress loop then sorts by ...
user avatar
  • 3
0 votes
1 answer
36 views

ACF flexible content block not showing on live site (works locally)

I've made a flexible content section in ACF for a specific category that allows the user to post text and different image galleries onto their post. This all works perfectly whilst I'm on my ...
user avatar
  • 1
0 votes
0 answers
5 views

Only the most recent post is showing on my category page (working on localhost, not live site)

This is the code I have for my content.php page and it works completely fine on my local host, showing all the posts but now I've made the site live, only the most recent post shows, and it also now ...
user avatar
  • 1
0 votes
0 answers
25 views

posts_per_page in custom WP_Query does not override "Reading" settings?

I am trying to use WP_Query loop (below) to show all instances of a certain post type. (This loop is not in the custom post type’s archive — it is in a template part that appears as a page section on ...
user avatar
  • 1
0 votes
1 answer
20 views

How to display post tag on each post? [closed]

I need to display it on each post.
user avatar
-1 votes
1 answer
19 views

I need to update the post query? [closed]

I am trying to simply update the post query to only query posts with the taxonomy.
user avatar
0 votes
2 answers
29 views

Moving wordpress to different url/server creates redirect loop

I'm trying to move my wordpress site in to different server and url. How ever i seem to have a persistent redirect loop problem. I think this is not a cache, cookie or plugin problem and I am ...
user avatar
0 votes
1 answer
25 views

Getting blog pagination to work on page set as front page

From what I understand, if the page is the front page (using front-page.php) you would use get_query_var('page') and for other pages you would use get_query_var('paged'). I have a condition for this ...
user avatar
  • 105
1 vote
1 answer
57 views

Group and list posts by custom taxonomy

I'm trying to list posts from a CPT named "exposition" and group them based on a custom taxonomy called "date-exposition" (which are meant to be years such as 2010, 2015, 2017,...) ...
user avatar
0 votes
1 answer
51 views

How to display list of custom post taxonomy terms and their posts (if any)?

So I've created a custom post type (location) and a custom taxonomy (city) to go with it. I'm trying to set up a page where it lists the taxonomy terms followed by any posts associated with that term. ...
user avatar
0 votes
0 answers
15 views

How to separate two columns from one content on a page template?

I am just creating my first serious web project built on Wordpress and during my task (basically learning by doing) i came to a following problem. The designer wants to show two columns of text on ...
user avatar
  • 1
0 votes
0 answers
66 views

Is it possible to set archive.php instead of index.php to display blog?

I have index.php and archive.php in my theme, but I'd like to using archive.php to display blog and category posts. Is it possible to override index.php by archive.php?
user avatar
  • 1
0 votes
0 answers
12 views

i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress

I used the default from the documentation to create a custom cron intervals in a custom plugin payment gateway: I added in the construct the line: add_filter( 'cron_schedules', array( $this, '...
user avatar
0 votes
1 answer
15 views

Want to change the post every three days with in specific category

I have one post on homepage of a specific category. I want it to change after three days and pick the next post of the same category. Is it possible?
user avatar
0 votes
0 answers
13 views

How can I use arrays and a foreach to generate many lists with WP_Query?

I have a number of posts that I would like to show in a sorted list according to two properties. I want the end product to look like this: 1. Florida A. National Parks -list of ...
user avatar
0 votes
1 answer
25 views

How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?

I am a newbie developer who is still learning, and at the moment I am developing my very own first wordpress custom theme. However, I am struggling to get this working. I Have a "Hero" ...
user avatar
1 vote
1 answer
30 views

Show scheduled posts in main loop but not in WP_Query?

The blog page should show scheduled posts in the main loop. I've done that with this code: /** * Show scheduled posts in main loop */ function fa_show_scheduled_posts( $query ) { if( $query->...
user avatar
  • 155
0 votes
2 answers
109 views

First archive page with a few posts

I'm looking for a way on how to display only a few posts on a first page of my archive. This is my archive template — page-archive.php, which I am using as a template to display all my posts/recipes: &...
user avatar
0 votes
1 answer
24 views

Loop increase in while loop not working

I'm aiming to create a layout where the first post is full-width in the loop, all the posts after are 50%. I created this code: <?php if ( $query->have_posts() ) : ?> ...
user avatar
0 votes
2 answers
23 views

hide specific div on single.php [closed]

I've been working on WP since a week so far i've seen bunch of tutorials and videos about wp but i feel stuck and since i'm a wp noob i cant find or think any solution for a simple problem. i have ...
user avatar
  • 11

1
2 3 4 5
66