Tag Info

New answers tagged

1

$_GET refers literally to ?p=1 part of URL. With pretty permalink if it's empty then there is nothing to access. WordPress processed either case into query variables of WP_Query class. You should use get_query_var() to retrieve things like this, so in this specific case it would probably be get_query_var( 'p' ).


1

There might be better ways using filters or apache/nginx rewrites, but here are two ideas to consider from the admin UI point of view (untested): Idea 1: You can always visit /wp-admin/options-general.php change the whole the site url: but I don't think you're looking for that, since this will also change the home url. Idea 2: You might therefore ...


1

It's a pretty simple solution - WP_Query utilizes the name variable for posts and custom post type posts. It utilizes pagename for pages, hence why ?name=product1-faqs is not working. Use this instead: add_rewrite_rule('product1/faqs/?', 'index.php?pagename=product1-faqs', 'top');


1

From performance point of view what takes time is matching URL against generated (and stored persistently so it's not rebuilt continuously) list of regular expressions. Since URLs are (most of the time) insignificantly short in text volume the amount of those regular expression rules has most impact on performance. Unless you generate unreasonably many ...


0

In each of the web.config files for each directory, they will look much like this: <rewrite> <rules> <rule name="wordpress" stopProcessing="true"> <match url="*" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add ...


0

I've not tried external rules, but you can achieve that with an internal rewrite and pagename: function wpd_page_rewrite(){ add_rewrite_rule( '^anothername/([^/]*)/?', 'index.php?pagename=$matches[1]', 'top' ); } add_action( 'init', 'wpd_page_rewrite' ); For parent/child pages you have to set pagename to the parent/child ...


1

I believe this should handle it for you. Including monthly and daily. It also catches if you have defined a different rewrite slug than your custom post type slug. /* This function handles setting up Date archive rewrite rules for * ANY custom post type - You pass the CPT, and it will use the * re-written slug if applicable. */ function ...


0

I simply changed it to this, and it works! add_action( 'init', 'addMyRules' ); function addMyRules(){ add_rewrite_rule('^people/([^/]*)/?','index.php?author_name=$matches[1]','top'); add_rewrite_tag('%author_name%','([^&]+)'); flush_rewrite_rules(); }


0

While looking for a solution I got this post: Taxonomies with same slug as CPT So basically you need to add custom rewrite rules, I haven't tested the solution but I guess it will work out for you. /* Register CPT */ function wpse_138987_post_type_filter() { register_post_type('filter', array( 'labels' => array( 'name' => 'Filter', ...


1

Instead of index.php/reco/?b=$1, try this: "$wp_rewrite->index?pagename=reco&b=" . $wp_rewrite->preg_index( 1 ) You should also append a $ to your reco/([^/]*)/? regex to ensure the rule only matches the entire path, and not just the beginning. Then flush your rules afterwards (just re-save your permalink settings in admin). Update: Try using ...


0

I tackled subordinate post types with a similar vein but was not as strict on the canonical url aspect; however, I ran into a similar situation with deeplinking custom WooCommerce product type links. I leveraged the template_redirect hook to push a 404 if it didn't match the route and the post_type_link to ensure the meta tag for canonical link and all ...



Top 50 recent answers are included