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
21 views

how to loop through a specified array of categories

I need to create a template that lists all posts in a single category, then runs a secondary loop of categories specified in an array. For example: Page lists all posts "Award Winners". ...
1
vote
1answer
12 views

Display all taxonomy terms, add class if term applies to current post

I have a custom taxonomy for a custom post type. I need all available terms (and their descriptions) to display on a single post from this post type, regardless of if each term is applied to it. ...
0
votes
1answer
19 views

“Call to a member function have_posts() on array” error on have_posts();

I'm having the weirdest error. When trying to display a custom loop, I get the following error: Fatal error : Uncaught Error: Call to a member function have_posts() on array in /.../custom-page.php:42 ...
1
vote
0answers
18 views

Change query based on post type while staying in loop

I have a loop that displays three custom post types. Thing is, all of these post types use a different logic. 'elemzesek' and 'gyorshirek' use ACF fields which you can see in the meta_query. However, ...
1
vote
0answers
22 views

CPT Loop with ACF and passing ID between Loops

I have a staging site at: https://tozsdeforum.ethermedia.hu/ Near the top of the page, we have a "Kiemelt Hirek" section. In this section, there are five loops in play: IF (pos1 == true) {...
1
vote
1answer
14 views

Shortcode with a foreach and arguments

I'm digging into shortcodes expert level 😄 I made some searches and I really think I'm on the right path but I need your help because something is missing me (probably because I don't know very well ...
0
votes
0answers
13 views

How to remove first 3 posts on an archive page?

I am new to theme development and coding one theme from scratch, I have to build archive page where it will not show/ exclude first 3 posts. I tried below codes but it's showing same post on all the ...
0
votes
1answer
14 views

get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title

function custom_pic_alt( $attachment_ID ) { // Get ALT $thumb_alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true ); // No ALT supplied get attachment info ...
0
votes
0answers
17 views

How can I be able to check if current post in loop is the last on current page?

I developing a WordPress theme and for some reason, I want to be able to determine if am at the last post of the current loop page. How can I do this? <main id="main"> <!-- ======...
0
votes
0answers
7 views

Static content before posts in the loop, but after a sticky one when it exists

I have a custom home page where usually there is a sticky post followed by regular posts, and between them, a static content to indicate where regular posts start. It's something like this: STICKY ...
1
vote
0answers
22 views

Using the_post_thumbnail resets current loop item ID

I'm facing a very strange issue when displaying custom loop items (from a new WP_Query) on a static homepage template. Each item has a thumbnail, title, and some meta info. Every time I use ...
0
votes
0answers
8 views

Query Posts -> By ACF custom field Value

I'm using ACF and would like to create a query for the post_type elemzesek WHERE the given post has a custom field = get_field('ceg_megadasa') with the value of $ceg (the given company) Here's my loop:...
0
votes
0answers
15 views

Does Polylang auto-filter for posts language on language page?

SO, the following happened, and I just want to make sure that this is normal functioning, and I don't need to code a backup plan if this fails. Say you have a page A, whose language is set via ...
0
votes
1answer
41 views

How to loop custom post_type from (a) specific category(ies)?

I'm using this code which works really fine to list quite everything I need as Featured image and title, from my custom posts "portfolio". <?php $args = array( 'posts_per_page' ...
0
votes
1answer
14 views

Shortcode with loop stacks output

I found some shortcode to display a custom post type, but it's not display how I envisioned. Originally the shortcode only added the title from my custom post type, but I modified it to also show the ...
0
votes
0answers
14 views

Display custom type posts instead another custom type posts

I develope my WP site so I have 2 custom post types "cases" and "newcases". The "newcases" posts have new design and content. So I have more than 500 "cases" ...
0
votes
1answer
19 views

Custom Loop with certain number of one category

I have a custom loop that shows 120 posts in total on a certain page. The posts are from several categories. That works perfectly. But I need to change it. I need: 120 posts only of the category 2 ...
0
votes
0answers
6 views

How to do batch by batch processing for all users?

I created a dashboard for users where they can see their daily Instagram data. So I need to run a cron job daily to iterate each registered users and get their instagram data. This is my code: ...
1
vote
0answers
19 views

Split loop to load WordPress gallery into Bootstrap modal and carousel

I have created WordPress coding to loop through gallery images from a post, create a thumbnail gallery display in two cols (that resizes to one col at the mobile size, since the default WordPress ...
0
votes
0answers
29 views

delete an array element when its date expires

I have user levels for access content. I made a start date and end date input for each other. Each level has its own history. Whichever level date exceeds today's date, it will be removed from user ...
0
votes
0answers
12 views

Supless_filter / Wp_query / get_posts / Elementor button / Loop / geotargeting

I have the following problem Got geotargeting and custom post type (Jetengine) I then inserted everything into Elementor that I have a list with the posts with a "Load more" button (where a ...
0
votes
0answers
15 views

Pagination not working wit custom Query

I have created a custom Query that works perfectly with my custom post type, inside this custom post type I'm showing an archive with other custom post types: One is a city, and inside each city there ...
1
vote
1answer
36 views

How to order posts by meta_value created inside loop?

Inside the WP_Query, I'm trying to order posts by price. The problem is that the price value is not manually defined inside an ACF or so, but it comes from an api call made while looping trough posts, ...
0
votes
0answers
11 views

Displaying posts after ajax filtering

I'm fairly new to to this and struggling to get things working the way I want. Hope you can help :) I have a custom post archive page displaying art pieces. The user can filter which pieces are shown ...
0
votes
1answer
17 views

Add class every 4 post like , class_1, class_2, class_3, class_4 and class_1, class_2, class_3, class_4

Hey guys im trying to add a class every 4 post in wordpress loop like in the image above im using the simple loop of wordpress, I have investigated about using a counter or modulo but have not found ...
0
votes
1answer
112 views

update_user_meta as multiple value but with same meta key

I have this code. When I save it, the user levels adding and gives time select input next to it. But when I give different time to levels, for example: Level 1: 2 weeks, Level 2: 9 Months If saves ...
0
votes
1answer
29 views

how tho change number of posts in loop from specific categories

I am trying to get my home loop query filled like this: From all posts within all categories: show (just) 1 (most recent) post. From some specific categories: show 3 (most recent) posts (max). Sort ...
0
votes
0answers
8 views

How to display category names on the Blog Page(Post Page)

Hi everyone I hope your doing well, I'm having trouble on how to display the category names on the Post Page or my Blog Page, could anyone give me an idea on how to display the category names. Here's ...
0
votes
0answers
13 views

Filtering posts based on three taxonomies

I've built a filterable post listing where the user can filter based on two taxonomies, this is working but I now want to add a third taxonomy to the filter, but I think the logic I'm using isn't very ...
0
votes
1answer
24 views

Looping Through Categories of a CPT

I am trying to create tabs using the Foundations framework, outputting posts from a custom post type called testimonial and filtering them through their assigned custom category called filed-under. ...
0
votes
0answers
7 views

Auto comment on WordPress post using a button

I want to display a button on all the post archives. When we click that button it should post a comment on the post with one predefined line of text. here is an example link but it's not on WordPress. ...
0
votes
1answer
14 views

WP_Query breaking the loop in a nested loop

I'm not able to figure out the solution for the following code. When I remove the query section, the location loops but with the code, only one result of location (parent loop) is displayed. if (...
0
votes
0answers
13 views

“Post List” Loop containing other “Child Post List” loops causes pagination error ELEMENTOR

I am using a loop template to display posts in a custom template. The loop template contains another loop to display a list child posts. Child post list requires paginaion, but I am encountering a bug ...
0
votes
0answers
43 views

Error with Custom post type page with custom loop showing custom post taxonomy term by slug

I have a website with custom post type Pages called 'mini_site_page' I also created a custom post taxonomy in Posts called 'mini_site' and I check taxonomy inside the custom pages I want to show ...
0
votes
0answers
9 views

Display two items from a custom post type that have 2 different taxonomy terms but output different HTML in the loop for one of those terms

sorry if my question title does not make much sense, I couldn't think of a good way of wording it. Essentially, I currently have some custom loop code on single.php that does the following: If a ...
0
votes
1answer
26 views

ACF: How can I publish values of ACF fields in a loop while using wp_query?

I'm using ACF to add fields to a custom post type. I've created an instance of WP_Query to set up a loop. Within the loop I can publish the standard fields using the_title() and the_content(). However,...
0
votes
1answer
46 views

Insert content above an embedded video inside Wordress' php the_content

I'm a long time beginner in Wordpress theming (i do bits here and there for myself) and have a question. I run a very large website and i'm trying to redesign it (responsive etc) and have run into a ...
0
votes
0answers
14 views

I want to display parent and child posts in a lists

I need display custom post type posts list same as menu till n level. Below is the flow chart how I need to display. Post 1 Child Post 1 Child Post 1 Post 2 Child Post 2(A) Child Post 2(A) ...
0
votes
0answers
14 views

Creating a User-Adjustable chart in Wordpress

I am new to WordPress and I need to create a 'calculator/chart'. I have an excel file with a chart whose values are pulled from different tables with separate formulas, each table having its own set ...
1
vote
1answer
45 views

Filtering posts from different categories into different section by doing WP_Query only once

I am trying to create a custom homepage with multiple categories section. I know this is possible with WP_Query, but i don't want to make multiple db trips. I want to query posts (say 5 each) from ...
0
votes
0answers
23 views

Show all entries from an ACF Field

I have used ACF Pro fairly successfully thanks to these forums and I am back once again for help as I am clearly not a programmer! I created a new WYSIWYG field and added it to my Custom Post Type. I ...
0
votes
0answers
58 views

Undefined index: page in loop load ajax content

as the title suggests I get this error. (Notice: Undefined index: page in /Users/denis/Sites/www.testpepe.dev.cc/wp-content/themes/bubi/functions.php on line 429) Php code: <?php function ...
1
vote
0answers
18 views

Return the latest post from a custom Taxonomy and Post Type

CPT called: updates Custom Taxonomy called: systems What I was trying to do was loop through all my posts in a CPT and display the '1' latest post from each of my 'I think they're called Terms' (it's ...
0
votes
0answers
12 views

Woocommerce (Storefront) custom list view

Woocommerce does not come with a native list view so I wanted to create one without a plugin. I set the items per row within the customer to 1 and now I am trying to align the image to the left and ...
0
votes
0answers
6 views

Custom theme not working with elementor builer

I am building a theme and I would like it to be working with Elementor but for some reason, I don't understand I get the preview cannot be loaded error (We, re sorry, but something went wrong ....). ...
0
votes
1answer
28 views

How do I add filter with woocommerce categories?

I have created a loop that displays products, however I have ran into a problem when trying to filter them. I have added in tax_query because that is how to filter the search with taxonomies(based on ...
0
votes
1answer
27 views

How do I make my terms for each product display via foreach loop? (woocommerce)

This is my current loop to display my products via woocommerce. When I do print_r($category_array); It returns the array, but when I try to use a function to call it so I can do what I want to with ...
0
votes
0answers
27 views

Wordpress next post by ajax call on button click

I have an archive of custom post type "Trivia" where I want to display next custom posts on click of a button "Next Post" I have this code for displaying 1 post on archive page: $...
0
votes
1answer
23 views

Wordpress Insert ads after every 5th post

Hi I want to create a single archive page where every custom post will get displayed on click of a button and after every 5th post I can add an Ad image which can be fetched as another posts type I ...
0
votes
0answers
10 views

how to display next previous pagination on custom page?

I tried to add pagination my custom page, the pagination number appears but there is no next and previous pagination. function.php function pagination($pages = '', $range = 4) { $showitems = ($range ...

1
2 3 4 5
64