Post custom permalink results in 404 for archive page

You can override the Post type object settings in the init action and register the proper values for the archive and rewrites: add_action(‘init’, ‘my_init’); function my_init() { $args = objectToArray( get_post_type_object(‘post’) ); $args[‘has_archive’] = ‘news’; $args[‘rewrite’] = array( ‘slug’ => ‘news’, ‘with_front’ => FALSE, ); register_post_type(‘post’, $args); } function objectToArray( $object ) { if( !is_object( … Read more

Move WordPress site from one domain to another

There are a number of ways to do this, Install WordPress on new host, export, then import post data (via Dashboard) XML file Install WordPress on new host, export, then import MySQL database file Use a back up plugin that allows you to clone your site from host-to-host (1:1) In both cases 1 and 2, … Read more

How does one flush rules on theme activation or deactivation only?

While the solutions provided here do still work, WordPress has evolved since and does now (since 3.3, I believe) provide direct hooks for theme activation. after_switch_theme will fire on theme activation and switch_theme before deactivating an old theme. Hence the up-to-date answer is: function reflush_rules() { global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action( ‘after_switch_theme’, ‘reflush_rules’ );

WP get_permalink Return Wrong URL

IMO It is rarely a good idea to evaluate shortcodes outside of the specific post page as too many times you need the context for either the evaluation itself or styling. Your problem is most likely related to the use of the_post and wp_reset_postdata. What is exactly the post being reset to in that case? … Read more

Rewriting search permalink

WordPress doesn’t know that you want the path /searchmyblog/ as search result base. So when it sees the a it tries to find the best match – in your case a post starting with this letter. To fix that you could modify my code for the pagination base to change the search base: if ( … Read more

Permalinks for quote authors

Create a custom taxonomy quoteauthor, activate pretty permalinks, and you get nice URIs automatically. These URIs will not put the author’s name right behind the root, but something like /qa/steve-stevenson/ should be good enough. Here is a sample code as a plugin, you can download it on GitHub <?php # -*- coding: utf-8 -*- /* … Read more