Hi all:
In order to preserve URLs from our current Drupal site, I need blog posts on my new WordPress site to be of the form /blog/2015/05/some-cool-blog-post.
That's fine, except that if I just add /blog into the permalink I think this will happen to all my posts, which I don't want. I want this to be added only for posts in the Blog category.
Following some links on the Codes, it looks like I can hook into the permalink generation code and add the "blog" element when needed. But my efforts to do something even quite simple don't work.
I'm running this code in the functios.php file of my child theme:
function append_query_string( $url, $post, $leavename ) {
//if ( $post->post_type == 'post' ) {
$url = add_query_arg( 'foo', 'bar', $url );
//}
return $url;
}
add_filter( 'post_link', 'append_query_string', 100, 3 );
add_filter( 'post_type_link', 'append_query_string', 100, 3 );
I'd expect this to add the meaningless query var foo=bar to all my post URLs. But this isn't happening.
Do I need to reset, flush or restart something? Am I hooking into the wrong filter(s)?
Any thoughts appreciated.
Thanks,
Steve Lane