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

    Hi there,

    great theme and forum!

    I would like to use only a couple of post formats for the blog and want to add a new one:
    standard
    link
    quote
    alert (new)
    gallery (hide)
    video (hide)
    bild (hide)
    audio (hide)

    1. How can I hide some post formats in the backend (on the right sidebar listing all formats)?

    2. Can I add some default WordPress post formats that you didn’t include, like aside and chat?
    This didn’t really work: https://kriesi.at/support/topic/how-to-add-new-post-format/#post-224776
    I already found out in the forum that it is not easy to create a new post format and I also don’t want to use the workaround with custom post types. My target group using WP should only learn how to create a post. So maybe I abuse an existing format, which leads to the next question:

    3. If I cannot use a brand new format, how can I customize an existing post format?
    It is supposed to be an “alert” kind of post format, so I want the users to be able to choose a format called “alert” in the backend, so that the frontend shows a different icon and different color to red for the <div class=”blog-meta”></div>

    This in red with different icon and color: Example

    Thanks in advance!

    Daniel

    • This topic was modified 10 years, 8 months ago by Yigit.
    #229758

    Hi Daniel!

    WordPress does not allow for custom post formats in any way right now. From the codex:
    New formats cannot be introduced by themes or even plugins. .
    https://codex.wordpress.org/Post_Formats
    You can add support for other formats in the main functions.php file:

    /*
     *  add post format options
     */
    add_theme_support( 'post-formats', array('link', 'quote', 'gallery','video','image','audio' ) );
    

    You would then need to add new code for each format in includes>helper-post-format.php or replace the functions/add new functions. The styling changes are much easier in that you only need to target the front end post type selectors and then re-color/re-style things as needed.

    Regards,
    Devin

    #230031

    Hi Devin,

    mmh, it didn’t work so far. I am using a child theme. Do I have to do the changes in the parent theme?

    What I did (all in the child theme):
    I added this to the functions.php, so that i just have audio addded. The default format doesn’t need to be added, I guess.

    /*
     *  add post format options
     */
    add_theme_support( 'post-formats', array( 'audio') );

    to the includes>helper-post-format.php:

    <?php
    
    /*
     * 	The loop-index.php file is responsible to display wordpress blog posts
     *	Since this theme supports post formats (different styling and behaviour of certain posts, for example galleries, tweets etc)
     *	the output of the  loop-index.php file is filtered before it is passed to the users browser.
     *
     *	The filtering takes place in the functions defined in this file
     */
    
    // ========================= default post format ============================
    
    add_filter( 'post-format-standard', 'avia_default_title_filter', 10, 1 );
    
    // ========================= audio post format =========================
    
    add_filter( 'post-format-audio', 'avia_audio_content_filter', 10, 1 );
    
    // =============================================================================================================================
    
    /**
     *   The avia_default_title_filter creates the default title for your posts.
     *   This function is used by most post types
     */
    if(!function_exists('avia_default_title_filter'))
    {
    	function avia_default_title_filter($current_post)
    	{
    		if(!empty($current_post['title']))
    		{
    			$heading = is_singular() ? "h1" : "h2";
    	
    			$output  = "";
    			//$output .= "<{$heading} class='post-title entry-title ". avia_offset_class('meta', false). "'>";
    			$output .= "<{$heading} class='post-title entry-title' ".avia_markup_helper(array('context' => 'entry_title','echo'=>false)).">";
    			$output .= "	<a href='".get_permalink()."' rel='bookmark' title='". __('Permanent Link:','avia_framework')." ".$current_post['title']."'>".$current_post['title'];
    			$output .= "			<span class='post-format-icon minor-meta'></span>";
    			$output .= "	</a>";
    			$output .= "</{$heading}>";
    	
    			$current_post['title'] = $output;
    		}
    
    		return $current_post;
    	}
    }
    
    /**
     *  The avia_audio_content_filter checks if a audio embed is provided and extracts it
     *  If no slideshow is set, it checks if the content holds a video url, removes it and uses it for the slideshow
     *  The filter also sets the height of the slideshow to fullsize, and even on overview posts all slides are displayed
     */
    if(!function_exists('avia_audio_content_filter'))
    {
    	function avia_audio_content_filter($current_post)
    	{
    		preg_match("!\[audio.+?\]\[\/audio\]!", $current_post['content'], $match_audio);
    
    		if(!empty($match_audio))
    		{
    			$current_post['before_content'] = do_shortcode($match_audio[0]);
    			$current_post['content'] = str_replace($match_audio[0], "", $current_post['content']);
    		}
    
    		return avia_default_title_filter($current_post);
    	}
    }

    But i still see this in the backend:

    And all post with different post formats (like gallery) still show up in the blog.

    Any idea what else to try?

    #230034

    Ha! It works, when I modify the functions.php in the parent theme. But that would make a child theme obsolete. So any ideas how I can still use the child theme?

    Do I have to copy the entire parent’s functions.php then to the child’s functions.php?

    #231057

    Hi!

    Try to add this code to your child theme:

    
    add_action('init','avia_child_theme_setup');
    function avia_child_theme_setup(){
    add_theme_support( 'post-formats', array( 'audio') );
    }
    

    Regards,
    Peter

    #232399

    Hi Dude,

    thanks for your help – that worked well to reduce the number of post formats displayed in the backend.

    How do I have to insert the code for the child theme’s functions.php in order to make adjustments of the post format entypo-fontello icons that can be found in the parent’s theme functions.php (line 154 ff). Or can I simply use CSS to adjust that? If yes – how?

    $avia_config['font_icons'] = apply_filters('avf_default_icons', array(
     
        //post formats
        'standard' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue836'),
        'audio'    		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue921'),
    
        				
        //social		
        'behance' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue915'),
    	'dribbble' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8fe'),
    	'facebook' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8f3'),
    	'flickr' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8ed'),
    	'gplus' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8f6'),
    	'linkedin' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8fc'),
    	'instagram' 	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue909'),
    	'pinterest' 	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8f8'),
    	'skype' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue90d'),
    	'tumblr' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8fa'),
    	'twitter' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8f1'),
    	'vimeo' 		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8ef'),
    	'rss' 			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue853'),  
    	'youtube'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue921'),  
    	'xing'			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue923'),  
    	'soundcloud'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue913'),  
    	'five_100_px'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue91d'),  
    	'mail' 			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue805'),
    					
    	//woocomemrce    
    	'cart' 			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue859'),
    	'details'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue84b'),
    
    	//bbpress    
    	'supersticky'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue808'),
    	'sticky'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue809'),
    	'one_voice'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue83b'),
    	'multi_voice'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue83c'),
    	'closed'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue824'),
    	'sticky_closed' => array( 'font' =>'entypo-fontello', 'icon' => 'ue808\ue824'),
    	'supersticky_closed' => array( 'font' =>'entypo-fontello', 'icon' => 'ue809\ue824'),
    					
    	//navigation, slider & controls
    	'play' 			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue897'),
    	'pause'			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue899'),
    	'next'    		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue879'),
        'prev'    		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue878'),
        'next_big'  	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue87d'),
        'prev_big'  	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue87c'),
    	'close'			=> array( 'font' =>'entypo-fontello', 'icon' => 'ue814'),
    	'reload'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue891'),
    	'mobile_menu'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8a5'),
    					
    	//image hover overlays		
        'ov_external'	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue832'),
        'ov_image'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue869'),
        'ov_video'		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue897'),
        
    					
    	//misc			
        'search'  		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue803'),
        'info'    		=> array( 'font' =>'entypo-fontello', 'icon' => 'ue81e'),
    	'clipboard' 	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue8d1'),
    	'scrolltop' 	=> array( 'font' =>'entypo-fontello', 'icon' => 'ue876'),
    
    ));

    Thanks for your support so far!

    Daniel

    #232570

    Hi!

    Thank you for using the theme. I hope you’re doing well today.

    You can add this on the child theme’s functions.php:

    add_filter('avf_default_icons', 'avf_change_default_icons', 10, 2);
    
    function avf_change_default_icons($icons) {
    	
    $icons['standard']	= array( 'font' =>'entypo-fontello', 'icon' => 'ue836');
    $icons['audio']	        = array( 'font' =>'entypo-fontello', 'icon' => 'ue921');
    return $icons;
    }

    Best regards,
    Ismael

    #232653

    Hi Ismael,

    worked perfectly!

    Thank you all for your kind help!

    You can close this one :)

    Best,

    Daniel

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Customize and hide some post formats’ is closed to new replies.