add_rewrite_rule query_var not being set

I have an unusual use of add_rewrite_rule (is there a usual use?) and I am getting some unexpected behavior. First here is my code: if(!empty($list_view_template)) add_rewrite_rule( “{$list_view_template}/(.*)?”, ‘index.php?mlscrit=$matches[1]/list-view/&pagename=” . $list_view_template, “top’ ); add_filter(‘init’, ‘mls_declare_mls_custom_vars’); function mls_declare_mls_custom_vars() { add_rewrite_tag( ‘%mlscrit%’, ‘(.*)’ ); } so as you can see I am using a pagename set within the … Read more

Taxonomy page template changing when using query variables

I’m hoping someone can help me fill in the gaps in my understanding of page templates and query vars: I’ve registered a custom taxonomy ‘stream’, and have set up a page template for that taxonomy, taxonomy-stream.php. The page template lists an archive of posts that are using the respective taxonomy term. Everything there works fine. … Read more

Is there a plugin to record querystring parameters for a page (for customer tracking)? [closed]

Closed. This question is off-topic. It is not currently accepting answers. Asking to recommend a product (plugin, theme, book, hosting provider), tool, library or off-site resource is out of scope of the site, as it attracts opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Closed … Read more

Why query_vars get altered in WP_Query Object?

I am having problems when querying a WP_Query Object when a user has a role different than administrator My WP_Query is this: function remove_new_c_post($author_id,$value_id) { $query = new WP_Query( array( ‘post_type’ => ‘custom_post_type’, ‘author’ => $author_id, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘value_id’, ‘value’ => $value_id, ‘compare’ => ‘LIKE’, ), ), ‘order’ … Read more

WordPress query through Products variation stock [closed]

Closed. This question is off-topic. It is not currently accepting answers. Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers’ support routes. Closed 2 … Read more

Rewrite URL Parameter And Force ‘Pretty’ Permalink

I’m trying to pass a variable via a URL parameter and rewrite + force ‘redirect’ it. In other words, I have: /dir1/dir2/?my_var=123 and I want: /dir1/dir2/123/ Through the following code in my functions.php file, I am able to achieve that: function setup_filter_rewrites() { add_rewrite_rule(‘dir1/dir2/([^/]*)/?’, ‘index.php?pagename=dir1/dir2&my_var=$matches[1]’, ‘top’); } add_action( ‘init’, ‘setup_filter_rewrites’ ); function setup_filter_query_vars( $query_vars ) … Read more

How to Modify Existing Rewrite Rules?

I’m attempting to modify existing rewrite rules generated by WordPress in order to override the default rewrite rules generated. I’m using the filter hook rewrite_rules_array to obtain an array of existing rewrite rules. While sifting through the rewrite rules array, there are rewrite rules containing $ in the array value. After replacing a set of … Read more

Passing array of strings to a SQL statement in a WordPress plugin

I have an issue with passing an array of strings to a SQL statement in a WordPress plugin, because the prepare method adds a backslash before each apostrophe. // I have an array of strings. $the_array = [‘red’, ‘green’, ‘blue’]; // I convert the array into a single string containing comma separated values surrounded by … Read more