Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

The core of the WordPress query, the loop offers an easy way to access post information and display it on your website.

0
votes
1answer
17 views

exchange words in echo

with this code $wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle); I exchange words in one of my loops. Now I am trying to change a word that is called with echo $...
0
votes
0answers
16 views

How to modify archive pages URLs to include dynamic prefix?

I am building a website in WP where content (news, announcements, events) are grouped by regions (e.g london, nyc, ...; these are custom post types). In all the contents, I have a meta box where I can ...
0
votes
0answers
8 views

Best Practice to display posts which contain a certain metadata

I'm working on a theme that allows the user to add meta data to a post. I want to display all the posts with my custom meta data on a front end page. However I am unsure the best way to go about ...
0
votes
1answer
14 views

WP_Query & Duplicate entries

I am currently using this code in order to get the latest three posts of my website, successfully and with no issues: $posts = get_posts( array( 'numberposts' => 3 ) ); but I want to switch to ...
0
votes
0answers
13 views

Split/group search results by post type?

So WordPress default search results/output page (search.php) searches for everything and displays everything. Pages and Posts together in my case. What I want is to spit these results. I tried it a ...
0
votes
0answers
24 views

My post loop needs to have 8 different post templates

Firstly let me just say I am a beginner with backend but have learned a lot the past few weeks working on this backend project my company has allowed me to work on. I've learned to use Ajax, create ...
-1
votes
0answers
13 views

How to use wp_query in different columns in single loop?

Solved I want use one wordpress loop display posts in a row as: <div class="row"> <div class="col-12 col-md-6"> post 1 </div> <div class="col-12 col-md-6">...
0
votes
1answer
39 views

Problem with php if else loop

I am new to coding. I am trying to get a different text on one of my button if the field is empty. The original code is: <?php if ( $clpr_options->coupon_code_hide ) { $...
0
votes
1answer
24 views

inserting content of 1 Post to in another with a template hierarchy

I have a page template I use for landing pages for various ad campaigns. The template uses custom fields for things like headlines and other shorter pieces of content within the page. However the ...
0
votes
1answer
29 views

Multiple Custom Post Type in Taxonomy Archive Causing White Screen

So basically I'm trying to add multiple custom post type in my taxonomy archive. Here's my code: <?php $args_trip = array ( 'post_type' => 'trip' , '...
0
votes
1answer
11 views

Adding a Section for Visitors

I habe a basic dog care website where I would like to have a lost dog section where visitors can post about their lost dogs with pictures and custom fields like communication and location info. But ...
0
votes
0answers
26 views

Why is the loop displayed (duplicated) outside the div.page? [on hold]

do you know why the loop result is displayed (duplicated) outside the div.page? The loop appears outside the template, on the top This is the code: // The Query $the_query = new WP_Query($...
0
votes
0answers
27 views

query problem for display with pagination

I developed a wordpress page template (which is supposed to display digital products that I sell on my site) that worked without problems for months, but since yesterday, the page template doesn't ...
0
votes
3answers
33 views

Regarding a custom loop and output HTML tags

I want to make the code to display the list of the page title in footer. I made the following code in functions.php: add_action('yamada_action', 'list_page_2'); function list_page_2() { ...
0
votes
0answers
20 views

problems with the Curl in the save_post

I would like a link outside the site to be recalled after saving a post. Ho due problemi: 1) Curl libraries are already slow in themselves. In addition, the Hooks "save_post" function goes into loop ...
3
votes
1answer
40 views

Why do I need to use The Loop on pages (inside page.php etc)?

This question is addition to the following question. The answers to the linked question say that you have to write THE LOOP inside each php template file, but what is still open is WHY? why is it ...
0
votes
1answer
21 views

ACF background-color per post in a WordPress loop

I have the following loop in WordPress: <div class="container"> <?php $news = array( 'post_type' => 'post', 'category_name' => 'angebote', 'order' =...
0
votes
0answers
10 views

Instant events in wordpress

I'm looking for a solution where I can have the blog page update automatically when a new post it's published without the page refresh. I could update the div every 10 seconds with content from ...
0
votes
0answers
29 views

Modify core files to display products by category

I'm pulling my hair over here searching and trying to modify the WooCommerce core files. So, what I am trying to do is modify my theme's woocommerce.php file because I want to display the products ...
0
votes
0answers
15 views

Latest post to style different and other post in loop

<div class="page blog-page-listing"> <div class="container"> <div class="page-title"> <h1>Recent Posts</h1> </div> <div ...
0
votes
1answer
30 views

display posts of custom post type with custom taxonomy

I have created a custom post type 'CPT_A' with CPT UI plugin. I have also created custom taxonomy 'Category_A' and 'Category_B' for 'CPT_A'. I have Posts 'Post_A', 'Post_B', 'Post_C', 'Post_D', '...
0
votes
1answer
15 views

Why is my loop not populating the page with my custom taxonomy terms from my custom post type?

Why is my loop not populating the page with my custom taxonomy terms from my custom post type? Currently it is displaying an empty box instead of pulling in the custom taxonomy terms from my custom ...
0
votes
0answers
18 views

Wordpress Query to show children of the current post using Elementor to design the page

I am trying to create a custom query to show the children of the current post. I am use the custom post type "services" and using Elementor as the theme builder. Elementor requires the query to be ...
-1
votes
1answer
23 views

how to handle multiple forloop?

I have and order_id as array but wc_get_order accepts only one id at a time how to loop through order_id and let the list of item id and item name? i am using this inside a class. it works fine if ...
0
votes
2answers
19 views

Show parent category and subcategory once in while loop

I have tried several things but unfortunately do not manage to do it in a good way. I use a while loop to pick up dealers (custom post type) from different countries and provinces. In this loop of ...
0
votes
1answer
30 views

List events by month

I am working on a WordPress site consisting of a custom post type called "events". Each "event" consists of a custom field called "event date". I'd like to organize all the "events" by months based on ...
0
votes
2answers
33 views

Last post in loop when even

I'm using this code to try and check the last post on each page loop is even so i can add different classes. This works to check if its the last post : ( ( 1 == $wp_query->current_post + 1 ) == $...
0
votes
2answers
27 views

Loop through posts? Want to remove extra newlines in actual post HTML/content on backend

I have a ton of posts that we created, but unfortunately there are a lot of blank spaces. This is an example of what I see on the backend, in the actual post: <h1>This is a post title</h1&...
2
votes
1answer
16 views

Last post is not showing up

I'm developing a custom template for a customer that wants in his website the possibility to filter posts by month. After creating an archive.php page and placing the widget "Archives" in my sidebar I ...
0
votes
0answers
11 views

Trying to get posts in a sub-subcategory of custom taxonomy

I have a custom taxonomy, which is structured like Cars --Ford --VW Trucks --Ford --Dodge And then I have posts in this post type such as "Beetle" and "Jetta" assigned to the "VW" subcategory and "...
1
vote
1answer
19 views

Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?

Objective: When a category is clicked I would like the category.php page to dynamically pull in all posts filed under that clicked category. Example: News -> (Action:Click) -> Category = News ...
1
vote
1answer
28 views

Custom get_the_excerpt() only works on first post

I use a custom get_the_excerpt function in my theme. It works perfectly for the first post in the loop, but the other posts are using the standard excerpt function. I do not understand why? The ...
0
votes
0answers
29 views

How can I get my pagination loop to display the correct number of total pages?

Currently my pagination is showing 7 posts on the first page and 6 on each page after. This is what I want. The current readout looks like this: . The total count of my pages changes as soon as I ...
0
votes
0answers
24 views

pagination for meta_post

I have some problem, I want to show my meta_post 2 per page (1 post have more than 1 meta_post), but my code still show all meta_post $metas = get_post_meta( $ids, 'value_gallery', false ); foreach (...
0
votes
1answer
20 views

How to pass current loop data into nested loop

I have a custom post type (activities) and on each post I loop through another custom post type (tours). In this second loop I want to create a variable containing the current post's name so I can ...
0
votes
0answers
14 views

make pagination on single-gallery with content from meta value

I have a file single-gallery and this content is image from meta_value , and i want make pagination for limit show image per page on all post , this my code $paged = (get_query_var('page')) ? ...
0
votes
1answer
15 views

How do I put my frontpage featured image in a page template for home.php?

Important: I want to makes sure this is clear: I am not asking how to get the post thumbnail. I am asking how to get the featured image for single page which is created through the Gutenberg editor ...
0
votes
2answers
30 views

List all posts associated under custom taxonomy

I have created a custom post type. Within that I have assigned two custom taxonomies. One (computer) is what I use to drive the template files and slug of page (taxonomy-computer.php). The second (faq-...
0
votes
2answers
45 views

The Loop not looping?

After much troubleshooting and searching, I think I finally understand how to get The Loop going. Except I can't seem to get it to actually loop! I have created a Child theme, and added a functions....
0
votes
0answers
20 views

How to display single post and the 3 previous posts on home and single

I am looking to have my site display a single blog post at a time, with the 3 previous posts displayed by thumbnail/title on the right. I was successful in getting this to work for the current post ...
0
votes
0answers
43 views

How do I use AJAX Query in my posts loop?

I have this function in my functions.php. All the AJAX and Query is working but displays the results of the loop right below the AJAX filter. I want the query loop to display in my main theme's ...
1
vote
1answer
25 views

What's the WP way to load remaining custom posts?

I am displaying custom post types, grouped under their custom taxonomies (basically used @ChipBennett's answer from here: Display all posts in a custom post type, grouped by a custom taxonomy) for a ...
0
votes
1answer
18 views

How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta

I hope I can explain this without being too confusing. I have a site where I have a custom post type that has two custom hierarchical taxonomies ( categories ) and each post also has a meta filed ...
0
votes
2answers
30 views

why get_post_meta is returning 0?

I'm trying to show all the posts on a page with an audio player in it and for that I'm looping through posts in the following manner: <?php $posts = get_posts(); $ID; foreach( $posts as $item) { ...
0
votes
1answer
19 views

show loop id post , only first id can read

I have a script , show post by id , and id post from array here my code : if ( have_posts() ) : while ( have_posts() ) : the_post(); $f = cherry_get_option('blog-featured-post',false); foreach ($f ...
0
votes
1answer
76 views

How to get post ID in a Page?

I'm trying to list all of my posts in a page(with post's content). Everything is showing correctly but the audio player which uses post id to get the URL of an attachment in the post is not showing. I'...
0
votes
0answers
11 views

How to include files in the loop via ajax

I create plugin and I need to include multiple files via ajax. When I don't use loop this code work: include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'sections/a.php' ); When I try to ...
-1
votes
1answer
18 views

foreach return displays double results

Seems I have a little bug in my WP code. When I add the shortcode to my page, it displays the results twice. If I use echo this will post at the top of the page, I want to enable to shortcode so it ...
0
votes
0answers
13 views

get archive link for custom post type for a custom taxonomy term

I have a couple of custom post type with a common taxonomy. I'm able to list custom taxonomy term page but having a problem with getting the archive link to the custom post type for that taxonomy term....
0
votes
0answers
16 views

Retrieve a specific ACF Repeater Sub field similar to a veriable

I have a veriable $journey_value = $_GET['onward-date'] != '' ? $_GET['onward-date'] : ''; And in a custom query I want to retrieve a specific acf repeater suv field simillar to the above veriable. ...