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

Any way to autogenerate a custom post with next 7 days of another custom post type in wp admin?

Currently, I have a custom post type of Event which uses WP_Query to get the next 7 days of events and places them into a carousel on the homepage. I am looking to further the functionality but ...
0
votes
0answers
9 views

How can I get the Second Value from a list of three

I have a short code in my theme's functions.php which fetches the city, state and country submitted by users. Using the code which is below, I want to get and display just the STATE only. function ...
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
13 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
16 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
25 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
19 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
7 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
14 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
29 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
12 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
9 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
15 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
26 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
23 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
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> ...
0
votes
0answers
16 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
10 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
18 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
9 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
13 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
0answers
13 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
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
38 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
69 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
26 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
27 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
25 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
16 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
25 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
19 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
23 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
17 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
85 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
24 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
16 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
15 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
22 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
27 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' ...

1
2 3 4 5
64