Need folder for CPT templates for eg: single-{post_type}.php

i was able to solve some of it // defining the sub-directory so that it can be easily accessed from elsewhere as well. define( ‘WPSE_PAGE_TEMPLATE_SUB_DIR’, ‘pages’ ); function wpse227006_page_template_add_subdir( $templates = array() ) { // Generally this doesn’t happen, unless another plugin / theme does modifications // of their own. In that case, it’s better … Read more

Admin metabox with custom post type dropdown option not update choosed input after saving

The issues with your code In the eca_meta_box_function() function, the selected option is not being selected because the option‘s value is not the post ID which is being used with the selected() function in WordPress: (wrapped for clarity) <option value=”<?php echo $post->ID; ?>_<?php echo preg_replace(‘#[ -]+#’, ‘-‘ ,$post->post_title ); ?>” <!– wrapped –> <?php selected( … Read more

Custom search for a custom post type in WordPress

Change operator to IN: array( ‘taxonomy’ => ‘features’, ‘terms’ => $feature_slugs, ‘field’ => ‘slug’, ‘operator’ => ‘IN’, ), That will query posts that have any of the terms in $feature_slugs, rather than all of the terms, which is what AND does. Also, I can see you’re using the POST method for this search. That type … Read more

Create dynamic logo carousel without using any plugin

You can create a custom post type for the logos as shown below, function create_post_type() { register_post_type( ‘logo’, array( ‘labels’ => array( ‘name’ => __( ‘Logos’ ), ‘singular_name’ => __( ‘Logo’ ), ‘add_new’ => __( ‘Add New’ ), ‘add_new_item’ => __( ‘Add New Logo’ ), ‘featured_image’ => __( ‘Add Image’ ), ‘edit_item’ => __( ‘Edit … Read more

Custom Post Type author filter not working

You can try this code <?php add_action( ‘restrict_manage_posts’, ‘admin_posts_filter_restrict_manage_posts_by_author’ ); /** * Create the drop down * * @return void */ function admin_posts_filter_restrict_manage_posts_by_author(){ if (isset($_GET[‘post_type’]) && ‘task’ == $_GET[‘post_type’]){ wp_dropdown_users( array( ‘show_option_all’ => __( ‘Show All Authors’, ‘your-site’ ), ‘name’ => ‘bcust_id’, ‘selected’ => $_GET[‘bcust_id’] )); } } add_filter( ‘parse_query’, ‘modify_query_to_filter_by_author’ ); /** * Filter … Read more

How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]

I think you have to create your own rewrite rule for that custom post type. Example creating a rewrite rule : function custom_rewrite( $wp_rewrite ) { $feed_rules = array( ‘reviews/(.+)/(.+)’ => ‘index.php?post_type=movies&taxonomy_name=”.$wp_rewrite->preg_index(1).”&post_name=” . $wp_rewrite->preg_index(2) ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( … Read more