Associate the “add_rewrite_endpoint” and “$_GET”

Query parameters added using add_rewrite_endpoint() are available using get_query_var(). So if you register /en/ as an endpoint: function wpse_318560_en_endpoint(){ add_rewrite_endpoint(‘en’, EP_ALL); } add_action(‘init’, ‘wpse_318560_en_endpoint’ ); And don’t flush rewrite rules on init. Rewrite rules only need to be flushed once. See this note in the developer docs for a way to properly flush rewrite rules … Read more

how to add extra GET parameters to post to url with add_rewrite_rule?

You want to use the add_rewrite_endpoint since what you are concerned with is at the end of the URL. function wpseo331941_reader_endpoint() { add_rewrite_endpoint(‘readers’, EP_PERMALINK | EP_PAGES); } add_action(‘init’, ‘wpseo331941_reader_endpoint’, 10, 0); //When you want to check if the ‘readers’ is being used if ( false !== get_query_var(‘readers’, false) ){ //…. } Note that the false … Read more

Special domain for a page

There is a plugin that does exactly this: https://wordpress.org/plugins/multiple-domain-mapping-on-single-site Anyway, it would be nicer to have things under control with an understandable few lines of script, so I’m still open to answers

Custom url for a plugin page add_rewrite_rule WordPress

After a long search finally i found a working solution. I am posting here in case someone face the similar issue, it would be helpful. Here is my working code: add_action(‘template_redirect’, array($this, ‘zip_template’)); add_filter( ‘rewrite_rules_array’, array($this, ‘zip_rule’) ); add_filter( ‘query_vars’, array( $this, ‘zip_query_vars’ ) ); add_action( ‘wp_loaded’, array( $this, ‘flush_rules’ ) ); /** * Rewrite … Read more

How much control do we have over CPT rewrite slugs? Can I create a “root” page for my CPT with out the page path, and then have paths for other pages?

The way I see it, you could do: // Via the init hook, do all these: register_post_type( ‘library-books’, [ ‘public’ => true, ‘label’ => ‘Library Books’, ‘rewrite’ => [ ‘with_front’ => false, ‘slug’ => ‘library/books’ ], ‘has_archive’ => ‘library/books’, // other args here ] ); register_post_type( ‘library’, [ ‘public’ => true, ‘label’ => ‘Libraries’, ‘rewrite’ … Read more

What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?

Yes, the post_link_category hook is indeed what you would use to filter the %category% replacement value in the permalink. And here’s an example with prominent_cat being the meta key and the value being the category name (e.g. Pizza Hut), where I’m using get_term_by() to get the category object/data: add_filter( ‘post_link_category’, ‘my_post_link_category’, 10, 3 ); function … Read more

Create multiple rewrite endpoints for custom taxonomy archive

This code above works fine up to one endpoint but not working for multiple endpoints like following https://example.com/dogs/shop/prod-cat1 https://example.com/dogs/shop/prod-cat2 https://example.com/cats/shop/prod-cat1 https://example.com/cats/shop/prod-cat2 Uses template shop-cat.php & value of query variable i.e prod-cat1, prod-cat2 available on template Your request hook callback is always setting the query var to true, like so (for the shop var): if (isset($vars[‘shop’])) … Read more

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