New answers tagged url-rewriting
0
via: https://cnpagency.com/blog/the-right-way-to-do-wordpress-custom-taxonomy-rewrites/
I needed to change the order of registering the taxonomy (make sure it's before CPT) and the CPT (make sure it's after registering any taxonomy).
Now
'rewrite' => array( 'slug' => 'resources/tags', 'with_front' => false ),
works as expected!
1
Why it happens
The error 404 on the th/<page slug> pages occurs because your custom rewrite rules overwrite the default Page rules which would otherwise load the correct Page (having the slug <page slug>).
How to fix the issue
If your permalink structure is /%postname%, i.e. example.com/<post slug>, then a simple fix to the error 404 is by ...
0
Not sure the rewrite rule is good, but to answer the question about getting the post meta - you already have the post Object, so you don't need to run a function to get the global $post, which might also fail or be wrong - you can simply use:
$metaText = get_post_meta( $post->ID, 'test_text_field', true);
You will probably also want to debug the value of ...
0
Nevermind, I was able to solve this by updating my $args in register_post_type. I set 'with_front' to false in my rewrite parameter for my affected custom post type and just updated my blog post permalink structure to /page-name/blog/%postname%/
'rewrite' => array('slug' => 'knowledge-base', 'with_front' => false)
-1
I have not found custom routes in WP mature enough.
I suggest you use any of the 3 routes solutions mentioned in Timber docs.
https://timber.github.io/docs/v2/guides/routing/
if you use Upstatement library (https://github.com/Upstatement/routes) you would do:
Routes::map('info/:name/page/:pg', function($params){
//make a custom query based on incoming ...
0
I have solved it, thanks to info gleaned from a 'related question' that showed up in the sidebar after posting mine.
The answer, found at Prettified page URL w/ query var redirects to prettified page URL w/o query var was to include the parent pagename as well as the child page name in the rewrite rule.
So instead of:
add_rewrite_rule(
'^c/(.{6}).*?$',
...
0
Thanks to the help of the link provided by @q-studio I was able to determine the correct course of action.
Firstly I setup an action to load the code in the init using the 'init' tags in an add_action(); within my functions.php file.
add_action( 'init', 'wpteaminfo_init' );
Then i created the function to setup my id variable with add_rewrite_tag(); then I ...
Top 50 recent answers are included
Related Tags
url-rewriting × 1911rewrite-rules × 537
permalinks × 451
custom-post-types × 380
urls × 264
custom-taxonomy × 203
htaccess × 177
redirect × 95
plugins × 84
slug × 81
plugin-development × 73
categories × 68
mod-rewrite × 66
php × 56
404-error × 53
multisite × 44
pagination × 44
customization × 39
pages × 38
taxonomy × 38
posts × 35
functions × 32
site-url × 32
archives × 28
templates × 26