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

Why query_vars get altered in WP_Query Object?

Milo’s comment about pre_get_posts helped solve this issue for me. In my case the parent theme used the pre_get_posts action to explicitly set the post_type for all author pages. It wasn’t in the functions.php, but I was able to find it by searching the theme for instances of pre_get_posts. (I used grep -R “pre_get_posts” . … Read more