get_query_var returns wrong default value

The default value of get_query_var( $var, $default ) is only returned if the query variable $var isn’t available in the global $wp_query object. The order query variable actually falls back to the DESC value here: if ( ! isset( $q[‘order’] ) ) { $q[‘order’] = $rand ? ” : ‘DESC’; } … within WP_Query::get_posts(), so … Read more

Changing WP_Query params with url Query Var

This code manually sets the order with the ‘order’ => ‘ASC’ declaration in the WP_Query arguments. $loop = new WP_Query( array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘product_price’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 4, ‘paged’ => $paged) ); If we want to pass a url parameter to that we could use something like: … Read more

Rewrite rule to prettify two $_GET variables while in a new endpoint from a page

I think you are using endpoints incorrectly. When a endopoint is created, a new rewrite rule is created using a query var with the same name of the endpoint; its value is taken from the string that follows the endpoint definition. So, if you register “my-endpoint” and build this URL: /page-slug/my-endpoint/123/some-string The endpoint is passed … Read more

add_rewrite_rule query_var not being set

In response to yivi’s inquiry, So I was able to solve the problem by putting the hardcode portion of the redirect string first as shown here: add_rewrite_rule( “{$list_view_template}/(.*)?”, ‘index.php?mlscrit=/list-view/$matches[1]&pagename=” . $list_view_template, “top’ ); Thanks!

Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?

First, everyone doesn’t say that. Everyone says to use admin-ajax.php for ajax, which is it’s meant for, not form submissions precisely. It’s not as popular and well covered, but there is actually different endpoint for form submission — admin-post.php. The reasons are, however, same. What you cannot do in your plugin is reliably load WordPress … Read more

Taxonomy page template changing when using query variables

The problem is that category_name is a reserved keyword for the built-in categories for posts. Almost anything category_* is reserved. You can find a list of reserved keywords at the following url: https://codex.wordpress.org/Reserved_Terms This includes, but is not limited to: cat category category__and category__in category__not_in category_name term terms Behind the scenes it sees that you’re … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)