selecting custom post types and taxonomies for hub page listing blocks
selecting custom post types and taxonomies for hub page listing blocks
selecting custom post types and taxonomies for hub page listing blocks
Single custom post type page redirect to 404 page
Sorting by Title for Post Archive Categories for Custom Post Type
using jetbooking for multiple custom post types
unfortunately I have no success with get_post_type() but get_queried_object() helped. I changed the code to: function post_type_slug() { $post_type = get_queried_object(); $post_type = $post_type->rewrite[‘slug’]; return $post_type; } add_shortcode(‘pts’, ‘post_type_slug’); and it’s working in text widget now.
Jacob’s comment got me on the right track. Here’s what worked for my issue: add_action(‘init’, ‘cpt_rewrite’); function cpt_rewrite(){ $args = array( ‘public’ => true, ‘_builtin’ => false, ); $post_types = get_post_types( $args ); if ( $post_types ) { foreach ( $post_types as $post_type ) { add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/([0-9]{2})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]&monthnum=$matches[2]’,’top’); add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]’,’top’); } } } I used get_post_types() to get … Read more
Finally I get the solution for the code. Thank you my friend @SallyCJ for helping me out. Here is the code: add_action( ‘publish_program-peduli’, ‘add_program_term’ ); add_action( ‘deleted_post’, ‘delete_program_term’); function add_program_term( $post_ID ) { $post = get_post( $post_ID ); // get post object wp_insert_term( $post->post_title, ‘program’ ); } function delete_program_term($post_ID) { $cat = get_post($post_ID); if ( … Read more
How do I display custom post type data in Team Table?
Group search results by post type, but having a unique heading for each section?
This function was introduced in WordPress 5.0, so if you’re running an older version of WordPress, you won’t be able to use it