Custom post type with two templates

Assuming post type is my-post-type. We can create a page template with custom query using WP_Query. Let’s say we create template-multier.php with the below code in the root directory of the active theme. <?php /* Template Name: Custom Post Type Archive */ //Custom header stuff here //Custom query for `my-post-type` $args = array( ‘post_type’ => … Read more

Custom post type archive page not showing on archive-posttype.php

Custom template should be archive-gallery.php instead of archive-posttype.php It’s archive-$posttype.php where $posttype is the custom post type slug. WordPress first looks for archive-$posttype.php and if it’s not available then chooses archive.php Update Same for the custom taxonomies also , the flow is: taxonomy-$taxonomy-$term.php –> taxonomy-$taxonomy.php –> taxonomy.php –> archive.php So for gallery_categories custom taxonomy use … Read more

Display subcategories in the filter on CPT

You need to hook in to the Posts list table using the manage_posts_extra_tablenav filter, but you can show the filter yourself by using the wp_dropdown_categories() function. The only two $args that you are really interested in are depth and taxonomy, but I’ve included all of the defaults below. Full details of the wp_dropdown_categories() function can … Read more

Foreach in get_post_types to apply a different filter per post type

Welcome to Stack exchange 🙂 Some other plugin ( or your plugin elsewhere ) may be getting executed later, and maybe adding some elements to the array. Try to give your hook a higher priority, replacing your tweak method with following… function tweak() { foreach( $this->get_post_types(‘objects’) as $type => $data) { if($this->setting(‘disable_bulk_’ . $type)) { … Read more

Meta Box doesn’t appear

Without adding your custom post type, it looks like you’ve got the function called wrong on the second one add_action(‘admin_menu’, ‘mytheme_add_box’); // Add meta box function referans_add_box() { Do you want to say add_action(‘admin_menu’, ‘referans_add_box’); // Add meta box function referans_add_box() {

User schedule a post?

Here’s one possible solution from many.. If user makes a post, he/she saves it as draft User selects a datetime when he/she wants to publish it It’s saved as post metadata, my_post_schedule_time in my example Disclaimer: this is just an example. It should work perfectly but it will probably require some tweaking, tuning, customization and … Read more