Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #239608

    I’ve created a custom post type which uses “Category” as a taxonomy. When I select “News” as a category in the Latest News widget, no items are displayed. Probably because these items are from another post type. Is there a way to fix this?

    #239987

    Hey FotografieDuo!

    You can define a new widget based on the existing newsbox widget. Insert this code:

    
    add_action('after_setup_theme','avia_load_additional_widget');
    function avia_load_additional_widget()
    {
    	if (!class_exists('avia_customcptbox'))
    	{
    		class avia_customcptbox extends avia_newsbox
    		{
    			function avia_customcptbox()
    			{
    				$this->avia_term = 'portfolio_entries';
    				$this->avia_post_type = 'portfolio';
    				$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 CPT', $widget_ops );
    			}
    		}
    
    		register_widget( 'avia_customcptbox' );
    	}
    }
    

    into your child theme functions.php or into enfold/functions.php and replace “portfolio_entries” with your custom taxonomy, “portfolio” with your custom post type, “Latest CPT” with your widget title/name.

    Best regards,
    Peter

    #240042

    Is it possible to do something similar with avia-shortcodes ?

    Say add a custom avia-shortcode in the template builder based on let’s say “Portfolio Grid” but using a different CPT ?

    Right now we’ve edited and created custom php files loading them using

    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths)
    {
    $template_url = get_stylesheet_directory();
    array_unshift($paths, $template_url.'/shortcodes/');
    
    return $paths;
    }

    But they don’t benefit from the features you keep adding unless we edit our files manually.

    #240067

    I’ve copied this code and pasted it in functions.php, but no new widget shows up in the widget area…

    #240615

    Hey!

    Strange because it works on my test server. Please create me an admin account and I’ll check why the code doesn’t work.

    Cheers!
    Peter

    #241110
    This reply has been marked as private.
    #242263

    Hi!

    I created a child theme with the code. You can edit the widget code here: http://test.fotografieduo.com/wp-admin/theme-editor.php?file=functions.php&theme=enfold-child

    I couldn’t get it to work with the parent theme though – I’m not sure why but maybe it’s because the child theme functions.php loads before the parent theme files.

    Best regards,
    Peter

    #242292

    Thanks Peter,

    Maybe I found the anwser why I doesn’t work with the parent theme. Another customization I did, didn’t work the day before yesterday.
    But yesterday it did, so somehow Ii suspect some files are cached (?). So I’ll have a good look at your code add it to the parent theme and wait a day so to see wheter or not the new widget shows up….

    I’ll keep you posted!

    Best regards,
    Arjan

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Latest News widget: show custom post type’ is closed to new replies.