All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
1answer
13 views

How to show specify category template for both parent and child category

I tried to create a category template apply for parent and child specify category. I has create a file name 'category-1.php , in this file I used the loop for get the list of post: <?php if (...
1
vote
1answer
13 views

Get a list of posts with associated meta_value

Recently I began to use the Custom Fields. I would like to display a listing of posts which contains the meta_key "oldtimer" and also get the corresponding meta_value. Here is the expected result: &...
0
votes
1answer
24 views

Display current post position in Elementor Posts widget

I'm using Elementor 2.6.8 + Elementor Pro 2.6.2 I'm designing an Archive template to display a list of Custom Post Types filtered by custom taxonomy terms. I'm using Posts Widget from Elementor Pro ...
0
votes
1answer
46 views

How can I group posts by months and years?

I have posts under a custom post type which I like to display in a page grouped by Year and Month. In the page template that I create, I managed to separate them by month, but still without grouping ...
0
votes
0answers
15 views

Nested tax query arguments returning function is returning wrong arguments

I'm outputting the skus of products that satisfy my tax query condition where multiple tax queries are nested by "AND". here is my code $args = my_brands_loop(['brand_name'=>'mytag','shapes'=>...
0
votes
0answers
40 views

Pagination inside the blog page not working

I have a widget which creates a grid with pagination. If I am using the pagination then it works fine when used on the page to display grid. But when I am using that in inside a blog post. The ...
0
votes
1answer
92 views

Exclude a Woocommerce product from WP_Query

I'm using a WP_Query for get products from categories, $default = array( 'post_type' => 'product', 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish'...
0
votes
0answers
25 views

Custom meta fields not showing up in WP_Response Object via custom endpoint

I created my own Custom Post Type called person and a corresponding end route. I can modify my posts with the endpoint, using functions as wp_update_post,wp_insert_post and get_posts. I am facing a ...
0
votes
1answer
44 views

WP ForLoop to compare meta information of posts to determine what post to display

The short of what I am trying to do here is: I want to display only one post based on a date stored in a custom field. I only want to display the post if it meets two conditions 1: The date needs to ...
0
votes
0answers
19 views

Error in the page of a CPT file in WordPress

I have a CPT of podcast type implemented in my WordPress. I had to do a type 301 redirection since the plugin that manages the podcasts (Seriously Simple Podcasting) did not let me modify the ...
0
votes
0answers
21 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
0
votes
0answers
31 views

Woocommerce featured products query no longer working

I have a query that's stopped working since Woo 3.6 upgrade I think. I'm trying to get products in a category that are featured. Any help would be much appreciated:) <?php ...
0
votes
0answers
37 views

how to get custom attachment url?

Is there a common method to get a custom attachment URL regardless of the plugin or custom code used? Say if I use ACF plugin I can create an image field and get the url with get_field('fieldname'); ...
0
votes
0answers
10 views

Substitute post with certain meta key in loop

I have some logic where a post can be a link to another object. And if it outputted on frontend linked post should be shown, not original. Now I have the following code in my template: $is_list_link =...
-1
votes
1answer
20 views

Help with showing text when something is entered in my search bar

I'm having troubles replacing text when there is something entered in the search form. As you can see in the image below i want to replace 'mijn gemeente' with the get_search_query text if i'm ...
0
votes
2answers
172 views

WP Query post__in not returning correct results

At the bottom of my page I am trying to display some recent projects based on a pre-selected list of post IDs. I have built a custom query to try and retrieve the 3 specific posts (WHERE ...
0
votes
1answer
110 views

Ajax buttons not working properly in WooCommerce when using wc_get_template_part

I have a custom loop on my website home page of best selling products. I am using wc_get_template_part('content', 'product'); to pull in the products. But when I click the buy button, the buy button ...
-1
votes
1answer
44 views

First post in loop displays twice

I have created a wp_query where I change the post format after every 4th post. Unfortunately, the first post is displaying twice which is surely something wrong with my modulo conditions. I appreciate ...
0
votes
1answer
57 views

AJAX Breaking Offset Argument In WP Query

I have been using AJAX on my website successfully and for my category.php page I need to use the offset argument. Unfortunately, AJAX creates complications with offset and I get the same posts looping ...
0
votes
1answer
22 views

How can I use WP_Query to sort 'event' custom post type by date?

I have a custom query that in another iteration I'm using to only display events in the future: $today = date('Ymd'); if ( is_post_type_archive('event')) { $eventPosts = new WP_Query(array( ...
0
votes
1answer
30 views

How to display sticky post always at the top (before regular post) in wordpress?

I am working on a wordpress code as shown below in which the modified post displays at the top. $temp_args = [ 'post_type' => array('current-channel', 'post', 'current-episodes'), '...
0
votes
2answers
40 views

WP_QUERY wrong ammount of posts

I have 16 published posts of type "portfolio". With the query below, "found_posts" is 16. Correct so far. I've set "posts_per_page" to -1 to see all of them. But only 8 of them get rendered. The ...
0
votes
1answer
44 views

post_type incorrect for custom post type

I am trying to display a different template depending on the post type. I have registered two custom post types called resource and contact. When I try to get the post type in search.php (using ...
0
votes
0answers
30 views

Sort custom post type by other custom post type field. (Places by their reviews average rating)

I'm trying to sort Places (first custom post) by its Reviews (second custom post) average rating. So, basically I have two custom post types, one is Places and the other one is Reviews. Reviews have ...
0
votes
1answer
40 views

How to add sort order to incremented and paginated category loop

I used this in a loop on a category template to get a numbered lists of posts that continues in the next page: <?php $mypage = (get_query_var('paged')) ? get_query_var('paged') : 1; $ppp = ...
1
vote
2answers
137 views

This AJAX Code Doesn't Work - Looking for elegant solution

I am trying to utilize AJAX on my WordPress site for posts as a user scrolls. I followed this tutorial but it has no effect on my WordPress website. I have used a plugin that works, but I'd much ...
0
votes
1answer
29 views

Query post with content only

I need to loop through the last 3 posts movie, but only those which have a content not empty. I used to do as follow when I used the ACF editor instead of the native one. movie-content refers to ...
0
votes
0answers
24 views

Problem with my loops

I am French. Sorry if i make mistakes. I have two problems. The first, I have a page that shows all paying activities sort by date. The 'posts_per_page' does not work When I put 10, it shows 8 ...
0
votes
1answer
32 views

Custom WP_Query id

I need to create a WP_Query that lists only a specific post of a post type, I already have this in the query, but my problem is that the query filter receives via get the ID, With that suppose I have ...
0
votes
2answers
37 views

Best choice for multiple loop in page?

My home page include five loop. currently i use wp_query but is it optimized ? best choice with get_posts ? my code looks like that // First loop $args_dogs = array( 'post_type' => ...
0
votes
1answer
86 views

Custom taxonomy.php not working

I have created a custom taxonomy called "series" (code below) and two pages: taxonomy.php and a taxonomy-series.php 1)I noticed that siteurl.com/series does not work I get my 404 page, but if I were ...
1
vote
2answers
131 views

Create A Loop With A Variable Number of Posts For Each Bootstrap Row?

I'm attempting to create a single WP loop, using a custom query, to display a custom-post-type - using Bootstrap 4 markup. The complicating part for me is, I'd like the number of posts for each row ...
2
votes
1answer
155 views

Group posts by custom field

I am trying to display a list of all child pages using wp_query and so far I have created a function that retrieves all the child pages for the current page, however I need to sort these pages into 2 ...
0
votes
1answer
36 views

How to change posts order on Category and Tag archives?

WordPress by default order posts in descending order by date. But I want them to be in ascending order by date. How do I turn the order to ascending only for tags and category? I don't want blog post ...
0
votes
1answer
21 views

Display posts side by side with custom query

I'm trying to organize my posts side by side but they keep being displayed vertically. This is my code: <div class="row agenda-box justify-content-start padding minheight-40"> <div ...
0
votes
1answer
50 views

Custom Query Pagination not working on static front page

I'm trying to add pagination to my site but it isn't working. Here's the code: <div id="gridcontainer" class="carousel"> <?php $currentPage = get_query_var('page'); $counter = ...
3
votes
1answer
27 views

Get array of posts from the current archive page loop

Classic WordPress loop (for example in archive.php) looks like this: if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', ...
1
vote
1answer
232 views

wp_query to find posts by year and month

I need to create sorting by year and month of custom post type in taxonomy archive page. Like this: Here is shown year, if post exists in that year. And Highlighted month if post exists in that ...
2
votes
0answers
44 views

Multiple WP_Query loops with Pagination Not Working

Please can anyone help me out here? I'm really stucked with this code. I want to create a multi post loop on my home page with each loop having its own pagination. The first loop is for recent post, ...
0
votes
1answer
49 views

Multiple Custom Post Type queries, how to DRY it up

I need to be able to display the latest post from 4 different custom post types and then use those posts inside a carousel. Everything is working fine but I'm not happy with how my code looks as I'm ...
0
votes
0answers
45 views

Staggering featured post using 'sticky'

So I have Custom post type that occasionally will have posts marked as 'featured' Client would like to use the 'sticky' feature of WordPress to pick which posts from the CPT are classed as featured ...
1
vote
2answers
78 views

Show post number in widget loop

It works in the category.php loop <article> <p>post-<?php echo $wp_query->current_post +1; ?></p> </article> <article> <p>post-<?php echo $wp_query-&...
0
votes
0answers
24 views

Create custom design for posts loop with pagination

I need to create a simple posts loop to be shown on the homepage (Meaning - I am in "page" and not "blog" or "archive" This is what I need: Display maximum of 5 posts there will be arrows on both ...
0
votes
1answer
336 views

WP Query - Posts Per Page not working in combination with category__in

I'm not sure whether it's a bug or i'm doing something wrong, but it doesn't seem like posts_per_page works at all when using category__in. My query is below, even though I've set posts_per_page to 1,...
0
votes
0answers
28 views

Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop

I'm aware there are already answers regarding this question (Insert html after certain amount of posts?). But I haven't managed to find a solutions to my specific problem. The post linked above rely's ...
0
votes
0answers
29 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
1answer
405 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
1answer
31 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
3answers
56 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
1answer
164 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', '...