Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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 NEW

    add_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 BUILDER

    
    add_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' );
    	}
    }
    #426822

    Hey Julie!

    Check out this Gist:
    https://gist.github.com/josueochoa/a6658b7b3d268d81f9a3

    Regards,
    Josue

    #426848
    This reply has been marked as private.
    #426853

    Yes, you can remove that line if you don’t use it, avia_newsbox will default to categories if no avia_term is provided.

    Regards,
    Josue

    #426855
    This reply has been marked as private.
Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Enfold: Declaring more than one content type’ is closed to new replies.