Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #372673

    Hi team,

    I’ve installed the plugin Types – Custom Fields and Custom Post Types .
    I’ve created several custom post types and taxonomies.

    May I know how to select specific taxonomy to display as post meta infos? Currently, by default, it displays all the taxonomies I created and registered with that custom post type. However, I just want to display a few selective taxonomies.

    I’m not a php developer but I think I have to edit the file loop-index.php somewhere along the lines

     echo "<span class='post-meta-infos'>";
                    $markup = avia_markup_helper(array('context' => 'entry_time','echo'=>false));
                    echo "<time class='date-container minor-meta updated' $markup>".get_the_time(get_option('date_format'))."</time>";
                    echo "<span class='text-sep text-sep-date'>/</span>";
    
                        if ( get_comments_number() != "0" || comments_open() ){
    
                        echo "<span class='comment-container minor-meta'>";
                        comments_popup_link(  "0 ".__('Comments','avia_framework'),
                                              "1 ".__('Comment' ,'avia_framework'),
                                              "% ".__('Comments','avia_framework'),'comments-link',
                                              "".__('Comments Disabled','avia_framework'));
                        echo "</span>";
                        echo "<span class='text-sep text-sep-comment'>/</span>";
                        }
    
                        $taxonomies  = get_object_taxonomies(get_post_type($the_id));
                        $cats = '';
                        $excluded_taxonomies =  apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'), get_post_type($the_id), $the_id);
    
                        if(!empty($taxonomies))
                        {
                            foreach($taxonomies as $taxonomy)
                            {
                                if(!in_array($taxonomy, $excluded_taxonomies))
                                {
                                    $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
                                }
                            }
                        }
    

    but can’t get on with the code. May I ask for some help here? Thanks!

    #372678

    Hi senso!

    Thanks for using Enfold.

    I’m not sure what you mean by “display as post meta infos”. Are you just trying to display some of your custom taxonomies? If so then you’ll want to try out our blog posts element. You can display posts from a custom taxonomy with that shortcode.

    If that’s not correct then send us a link and take a screenshot highlighting what your trying to do so we can get a better idea.

    Cheers!
    Elliott

    • This reply was modified 9 years, 12 months ago by Elliott.
    #372692

    Hi Elliott,

    Thanks for the prompt support. Sorry for not making myself clearer.

    I’m not trying to display posts from a custom taxonomy.

    Currently, the post-meta-infos is showing all the taxonomies registered with that post type. I wanted to show only selected taxonomy.

    I think I might have used the wrong term. By post-meta-infos, I was referring to what’s inside the red border of the attached image.

    • This reply was modified 9 years, 12 months ago by senso.
    #372698

    Hi!

    Try adding this to the bottom of your functions.php file.

    add_filter( 'avf_exclude_taxonomies', 'enfold_customization_exclude_taxonomies' );
    function enfold_customization_exclude_taxonomies( $t ) {
    	$t[] = 'category';
    	return $t;
    }

    And replace “category” with the slug of your custom taxonomy that you wish to exclude.

    Regards,
    Elliott

    #372707

    Hi Elliot,

    Thanks for the prompt reply. I edited the previous message before seeing your latest reply. Do ignore that.

    I think that is what I needed. May I check to exclude more than one taxonomy, do I do something like the below?

    add_filter( 'avf_exclude_taxonomies', 'enfold_customization_exclude_taxonomies' );
    function enfold_customization_exclude_taxonomies( $t ) {
    	$t[] = 'slug1, slug2, slug3';
    	return $t;
    }
    #372713

    Hi Elliot,

    On second thoughts, does editing the functions.php exclude taxonomies for all posts? I would like to specify selective taxonomies for different custom post types, will that be possible?

    For e.g.

    In Custom Post Type A, I want to show date, time and author.
    In Custom Post Type B, I want to show date, time, author, category and slug2taxonomy.

    p/s: Just realised I didn’t attached the image in my previous post #372692 http://imgur.com/QMXJPd2

    • This reply was modified 9 years, 12 months ago by senso.
    #372759

    Hey!

    It would look like this.

    add_filter( 'avf_exclude_taxonomies', 'enfold_customization_exclude_taxonomies' );
    function enfold_customization_exclude_taxonomies( $t ) {
    	$t[] = 'slug1';
            $t[] = 'slug2';
    	return $t;
    }

    Here is an example of how to check for a certain post type.

    add_filter( 'avf_exclude_taxonomies', 'enfold_customization_exclude_taxonomies', 0, 2 );
    function enfold_customization_exclude_taxonomies( $t, $pt ) {
    	if ( $pt == 'portfolio' ) { 
    		$t[] = 'portfolio_entries'; 
    		$t[] = 'slug2';
    	}
    	return $t;
    }
    

    Best regards,
    Elliott

    #481971

    Hi,
    I know it has been a while but just managed to try this out. :p
    The above works greatly!

    Sorry for asking for more, it returns without a comma for the taxonomies. how can I include a comma separator to the result?

    Thanks!

    #483398

    Hey!

    Send us a link to your page and paste the full code your using here so we can get a better idea.

    Regards,
    Elliott

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.