Rewriting a custom-post-type permalink with taxonomy term?
Change all your %event% to %event_type%. I hope that works for you.
Change all your %event% to %event_type%. I hope that works for you.
I think the latest major release warrants a new answer to this question, considering the popularity of this question. Since WordPress 4.7 (released December 2016) it is possible to add custom bulk actions without using JavaScript. The filter bulk_actions-{$screen} (e.g. bulk_actions-edit-page for the pages overview) now allows you to add custom bulk actions. Furthermore, a … Read more
I wouldn’t try to localize your slugs. Instead, why not give your users the option to change them by adding another field to the permalink settings page? Hook into load-options-permalink.php and set up some things to catch the $_POST data to save your slug. Also add a settings field to the page. <?php add_action( ‘load-options-permalink.php’, … Read more
You can remove the default meta boxes with remove_meta_box and re-add them in a different position with add_meta_box: add_action(‘do_meta_boxes’, ‘wpse33063_move_meta_box’); function wpse33063_move_meta_box(){ remove_meta_box( ‘postimagediv’, ‘post’, ‘side’ ); add_meta_box(‘postimagediv’, __(‘Featured Image’), ‘post_thumbnail_meta_box’, ‘post’, ‘normal’, ‘high’); } This will remove it from the side column and add it to the main column. change post in this example … Read more
There is a great Step by Step description on how to do that here https://www.jclabs.co.uk/create-custom-post-status-in-wordpress-using-register_post_status/ To add your custom post status to the drop-down menue, just add the following to your themes function script: add_action(‘admin_footer-post.php’, ‘jc_append_post_status_list’); function jc_append_post_status_list(){ global $post; $complete=””; $label=””; if($post->post_type == ‘recipes’){ if($post->post_status == ‘aggregated’){ $complete=” selected=\”selected\””; $label=”<span id=\”post-status-display\”> Aggregated</span>”; } echo … Read more
goldenapple’s initial answer gave me the jumpstart I needed to finish this up. functions.php Here is the complete code I’m using to add a new post type “header-image” and modify other admin screens accordingly: /** * Register the Header Image custom post type. */ function sixohthree_init() { $labels = array( ‘name’ => ‘Header Images’, ‘singular_name’ … Read more
Yes, you can. All you need is make a filter for wp_get_archives(); so it accepts post_type parameter: function my_custom_post_type_archive_where($where,$args){ $post_type = isset($args[‘post_type’]) ? $args[‘post_type’] : ‘post’; $where = “WHERE post_type=”$post_type” AND post_status=”publish””; return $where; } then call this: add_filter( ‘getarchives_where’,’my_custom_post_type_archive_where’,10,2); Whenever you want to display archive by custom post type, just pass the post_type args: … Read more
You can add an endpoint to your URIs to handle special requests. Here is a basic example as plugin. To understand what’s going on read Christopher Davis‘s fantastic tutorial A (Mostly) Complete Guide to the WordPress Rewrite API. <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Endpoint Example * Description: Adds a … Read more
This is what I use to rewrite custom post type URLs with the post ID. You need a rewrite rule to translate URL requests, as well as a filter on post_type_link to return the correct URLs for any calls to get_post_permalink(): add_filter(‘post_type_link’, ‘wpse33551_post_type_link’, 1, 3); function wpse33551_post_type_link( $link, $post = 0 ){ if ( $post->post_type … Read more
You’ll need the post object somehow, or, alternatively the queried object on post type archives. On a singular page you might do: $post = get_queried_object(); $postType = get_post_type_object(get_post_type($post)); if ($postType) { echo esc_html($postType->labels->singular_name); } Or in the loop: $postType = get_post_type_object(get_post_type()); if ($postType) { echo esc_html($postType->labels->singular_name); } In post type archives: $postType = get_queried_object(); echo … Read more