Redirecting when changing custom post type slugs?
All you need to do is add a line like: RewriteRule ^aboutus$ /about-us [R=301,L] In to your .htaccess file. The old url should go between the ^ and $ and then new url after the slash.
All you need to do is add a line like: RewriteRule ^aboutus$ /about-us [R=301,L] In to your .htaccess file. The old url should go between the ^ and $ and then new url after the slash.
You can use get_post_custom() which will return an array of all post meta in one single call to the database, that should save a few calls. And as for including the file over and over you could use get_template_part() to include a file once which will hold the entire loop (a good example can be … Read more
If you want to have more control over the filtering of your posts then separating the meta values into separate keys is the best option to go about it. Also what you could do is, only the values that would be required while filtering could be separated and the rest of them could go into … Read more
Update The answer is so simple, I couldn’t see it at first. 🙂 Just remove the action during the first function call. This way, your work within the API, and your function is really called just once. No need for static or even global variables or constants. function my_metabox_save() { remove_action( ‘save_post’, ‘my_metabox_save’ ); // … Read more
You can do this by setting ‘with_front’ => false while registering the new custom post type, To remove the custom post type slug which WordPress adds by default, pass ‘slug’=>” empty. E.g. //Example – how to pass array to rewrite $args = array( // This rewrite settings will remove the slug you want also the … Read more
I had this same issue of needing two archive pages for a custom post type. I was able to accomplish this fairly cleanly using four WP hooks For the example my custom post type is “member”. I need a second archive url for members that have a custom meta_key “plus” set to true. First we … Read more
It’s fairly inefficient to use query_posts and I often find it’s more trouble than it’s worth. Instead, to set the post type you can just have a hidden input inside the form with name ‘post_type’ and value (in this example) ‘news’. WordPress handles the rest. Unfortunately it is not so easy with taxonomies (maybe I’ve … Read more
What you want is a rewrite endpoint. You’re already familiar with these. WordPress’ urls that end with feed are simple a rewrite endpoint, and you can add your own! add_rewrite_endpoint takes two arguments: the endpoint you want, and the “mask” of where you want it to go. “mask” is just a number that you can … Read more
here is a simple shortcode that can handle taxonomies, post types and any other parameter that WP_Query takes: add_shortcode(‘posts’,’posts_shortcode_handler’); function posts_shortcode_handler($atts, $content){ extract(shortcode_atts(array( ‘posts_per_page’ => ‘5’, ), $atts)); global $post; $temp = $post; $posts = new WP_Query($atts); $retVal=””; if ($posts->have_posts()){ while ($posts->have_posts()){ $posts->the_post(); // these arguments will be available from inside $content $parameters = array( … Read more
I second Tom’s answer, however in the interest of answering your question, have a look at this question using the template_include filter.