Browsing Category

Wordpress wp-query

How to return a 404 when custom query matches nothing?

I’m using add_rewrite_rule() to create a new endpoint to my author URL. example.com/author/my-endpoint Here’s my code: // Pagination rule. add_rewrite_rule( '^author/([^/]+)/my-endpoint/([0-9]+)/?$', 'index.php?author_name=$matches[1]&my-endpoint=1&pag=$matches[2]', 'top' ); //

Create a sitemap without a plugin – get parent pages only?

I want to create a sitemap that only includes parent pages only. This is the code I use usually to get parent pages only: $args

How do I add a relation parameter to my filter query?

I am building an AJAX post filter using a single form with three select fields that allow the user to sort by three separate taxonomies

Convert SQL Query to WP_Query

I have been working with a third party wishlist module that causes some issues. Overcoming many of them I have one left. The architecture of

Where should you reset postdata?

I’ve searched for this in the Q&A but I was unable to find it. When I read answers throughout the site I see wp_reset_postdata() placed

Query 3 meta_key and orderby

I need to show the result of 3 queries and I made this query but I can not show the result, I throw a table

Meta query shows 3 posts instead of 4

I have external products which I don’t want to show in related products section in single product. Normally related products are 4 on my website,

pre_get_posts – Trying to get property of non-object warning

This code outputs the following warning when run on the pre_get_posts action: Trying to get property of non-object Which points to this line: if( 'edit'

please tell me the error in args array

please tell me the error in this code. $args = array( 'posts_per_page' => 5, 'post_type' => 'organisation', 'paged' => $paged, 'meta_query' => array( array( 'key'

WordPress query and pagination is not working

i am new to wordpress, here, what i am doing is fetching the thumbnails of post type= organisation, and i apply the pagination here, but

error with $query->have_posts()

i am new to wordpress, here, what i am doing is fetching the thumbnails of post type= organisation,please check if there is a problem with

Combine Tax Archive and Meta_Query in WP_Query

Want to return all “featured” posts and taxonomy archives to display details from. This gets all the featured posts: $args = array( 'post_type' => 'post_type',

Custom post type return 404 error on page 2 and afterward

I have 2 post types in my theme, the default post type and a custom article post type. I publish my posts under different categories,

Why my query returns 404 error on page 2 and afterward?

I have 2 post types in my theme, the default post type and a custom article post type. I publish my posts under different categories,

How to modify main query if there is a custom post type in it?

I have 2 post types in my theme, the default post type and a custom article post type. I publish my posts under different categories,

Woocommerce – Changing the order of the upsell products

Having some trouble with a clients site. We have a product with four upsell products linked, and they display on the site. Only problem is,

Back to Top 145132 wordpress questions, 32 Wordpress answers.
Wordpress related, All rights reserved
Powered by Creative Advertising