Tagged: CPT, Custom Post Type, enfold, functions
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
April 9, 2015 at 7:59 pm #426163
Hello!
Adding a single custom post type worked well. Now I will have more. Here are 3 code blocks I’ve used thus far (below). How do I continue to add more post types for each in the functions.php (child theme). New post types are “dev-military” and “dev-women”. Thanks for your help.
1- CHANGE BLOGS-LATEST NEWadd_filter('avf_title_args', 'fix_single_post_title', 10, 2); //changes blog latest news to title or static faq function fix_single_post_title($args,$id) { if ( is_singular(array('post', 'dev-daily'))) { $args['title'] = get_the_title($id); $args['link'] = get_permalink($id); $args['heading'] = 'h1'; } if( is_singular('faq') ){ $args['title'] = "Topical Q&A"; } return $args; }
2- ADDS CONTENT TYPE TO BUILDERadd_filter('avf_builder_boxes', 'add_builder_to_posttype'); //allows cpt dev-daily to use builder function add_builder_to_posttype($metabox) { foreach($metabox as &$meta) { if($meta['id'] == 'avia_builder' || $meta['id'] == 'layout') { $meta['page'][] = 'dev-daily'; /*your custom post type name here*/ } } return $metabox; }
3- ADDS LATEST NEWS WIDGET FOR CONTENT TYPE
add_action('after_setup_theme','avia_load_additional_widget'); //adds latest news widget for cpt function avia_load_additional_widget() { if (!class_exists('avia_customcptbox')) { class avia_customcptbox extends avia_newsbox { function avia_customcptbox() { $this->avia_term = 'dev-term'; $this->avia_post_type = 'dev-daily'; $this->avia_new_query = ''; //set a custom query here $widget_ops = array('classname' => 'newsbox', 'description' => 'A Sidebar widget to display latest cpt entries in your sidebar' ); $this->WP_Widget( 'customcptbox', THEMENAME.' Latest Devotion', $widget_ops ); } } register_widget( 'avia_customcptbox' ); } }
April 10, 2015 at 11:07 pm #426822Hey Julie!
Check out this Gist:
https://gist.github.com/josueochoa/a6658b7b3d268d81f9a3Regards,
JosueApril 11, 2015 at 12:10 am #426848This reply has been marked as private.April 11, 2015 at 12:33 am #426853Yes, you can remove that line if you don’t use it, avia_newsbox will default to categories if no avia_term is provided.
Regards,
JosueApril 11, 2015 at 12:34 am #426855This reply has been marked as private. -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- The topic ‘Enfold: Declaring more than one content type’ is closed to new replies.