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
8 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
6 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
24 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
0answers
11 views

How to display site title, if logo is missing in customize?

I want to display website title, if logo is missing in customize my codes for logo, functions.php add_theme_support( 'custom-logo', array( 'height' => 100, 'width' => 400, ...
0
votes
1answer
19 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
10 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
35 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
66 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
22 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 ...
0
votes
0answers
17 views

Woocommerce loop - remove hidden products

I've regular woocoomerce archive page. Products that should not be shown, are not shown, which is good. Now, the problem is that WooCommerce's default content-product.php template is doing checks like ...
0
votes
0answers
21 views

Is this so hard to do? Product gallery slider on archive pages [duplicate]

I have tried like 1000 diferent methods and the best thing I got was this: With this code: //* Add gallery thumbs to woocommerce shop page add_action('woocommerce_shop_loop_item_title','...
1
vote
1answer
9 views

Wordpress Loop - Not returning projects in specific category

I am attempting to simply pull in all projects in a specific category (e.g. 'websites' or 'featured'). When using: $args = array( 'post_type' => 'project', 'category_name' => 'websites', '...
1
vote
0answers
23 views

Filter the loop by categories using checkbox form

I feel I'm close in solving this issue but kinda hit a wall. I have a loop on the examlpe.com/blog site and I'd like to be able to filter it using the category checkboxes. Here is my loop <h3 class=...
1
vote
0answers
22 views

Wordpress Loop - Next 3 Posts

Hoping someone here can lend me some advice or point me in the right direction. I have a working Wordpress php function where I can get the next 2 posts in the loop of the current post within a post ...
0
votes
1answer
15 views

Query Nopaging action not having effect

I've got a custom loop function in my child theme, in the templates.php file to loop through specific post types ('listings') and then put it into an array to use into a part of my template. Here's an ...
1
vote
1answer
21 views

Missing image in gallery shortcode in custom feed

I have problem with custom gallery shortcode and missing first image in each gallery block. For example: [gallery ids="1,2,3,4,5"] show only 2,3,4,5 pictures. This custom shortcode is part ...
0
votes
0answers
15 views

Get title of page containing post grid within the posts

I have a page containing a post grid. Within the text of these posts I want to use a shortcode to display the title of the page containing this grid. So, when my page title is "test" I want ...
0
votes
0answers
22 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
16 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
41 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
18 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
15 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
21 views

Check if current post in loop is last on current page

I am developing a WordPress theme and want to determine if I am at the last post of the current loop page. <?php get_header(); ?> <main id="main"> <!-- ======= Blog ...
0
votes
0answers
8 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
21 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
15 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
15 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
8 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
43 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
30 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
17 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
16 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
12 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
124 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
14 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
8 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
15 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 ...

1
2 3 4 5
64