-2

The WP site I am creating requires creating diff posts for diff categories.

What I like is that if someone chose to post under category A, i have a bunch of pre-set settings (tags, banner image etc) in that post.

If the person posts under category B, there will be a diff set of settings?

Does anyone know if there's a plugin that can do this? I can hack the php code if i have to but i prefer a plugin where it is easier to manage.

The closest plugin I can find is ACF.

Thanks!

2 Answers 2

0

After scouring on the net and bouncing around, I figured out how to fix my problem.

  1. Install ACF and create your own post types.
  2. In Functions.php, add the following codes to default category for that post type.

    function add_pastorheart_category_automatically($post_ID) {
        global $wpdb;
        if(!wp_is_post_revision($post_ID)) {
        $pastorheartcat = array (15);
        wp_set_object_terms( $post_ID, $pastorheartcat, 'category');
    
        }
    }
    add_action('publish_pastors-heart', 'add_pastorheart_category_automatically');
    
  3. Also add this function to include the post type in the category.

    function namespace_add_custom_types( $query ) {
      if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'nav_menu_item', 'pastors-heart'
            ));
          return $query;
        }
    }
    add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
    
  4. For default thumbnail image, I put this code in the content-excerpt.php. Instead of checking for post types, I check for category.

It might not be the most elegant way of doing it. But it works for me.

0
-2

As per your description ACF will be enough and easiest way to do that. Create custom fields group based on your requirements (per category) then restrict them to specific post category with ACF rules.

Hope it will help you!

4
  • Hi Ruituparna, Thanks. My problem is that can ACF auto default a category when I create a specific post type? Most plug-ins I check can create specific post type and display or hide post settings. But i like to create a specific post type and a default category is enable for that post.
    – BigRedDog
    Feb 5, 2016 at 2:49
  • I really didn't understand what is your query!! what did you mean by "ACF auto default a category when I create a specific post type? " Can you give me an example? Feb 5, 2016 at 9:15
  • Hi Rituparna, i tested ACF and i see that it can pre-set a post to a category for specific post types. What i like to know is if there are ways i can pre-set other settings for specific post types. For example, set a default banner in the featrued image. I don't think ACF can do that. Thanks!
    – BigRedDog
    Feb 9, 2016 at 2:11
  • To set a default banner I don't think you are going to need anything other than a small coding. Like if (featured image set then show that) else (display the default image) Feb 9, 2016 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.