This topic has 4 replies, 2 voices, and was last updated 8 years by raniele.

  • Author
  • #79304
     raniele
    Participant

    Hello Devs
    I’m opening this thread as could not find any specific documentation.
    My situation:
    I’ve a CPT (custom post type) and created a single.php and archive.php pages for it. I need to customise the appearence of this CPT blog items in the archive page, namely I want to show metas and some custom fields on the blog item in the archive page.

    My question is what are the files involved to attain the desired result and where should they go. Looking at the code it seems to me that the needed hooks should go in any of the page-parts/post-content-(small, masonry or carousel).php files to be retrieved modfying my archive-myCPT.php just at the beginning of the loop (line 68), namely:

    <?php
    // Start the Loop.
    while ( have_posts() ) : the_post();

    /*
    * Include the post format-specific template for the content. If you want to
    * use this in a child theme, then include a file called called content-___.php
    * (where ___ is the post format) and that will be used instead.
    */

    if ($blog_type != ‘standard’) :
    get_template_part( ‘page-parts/post-content-‘ . $blog_type );
    else:
    $post_format = kleo_get_post_format();
    get_template_part( ‘content’, $post_format );
    endif;

    endwhile;
    ?>

    However I think I may have misunderstood the code instructions, as I can’t get it to work.
    What I did:
    -I created a post-content-myCPT.php file copying post-content-masonry.php (as that’s the view I need).
    -I put this post-content-myCPT.php in KleoChild
    -In archive-myCPT.php I changed get_template_part( ‘page-parts/post-content-‘ . $blog_type ); with get_template_part( ‘/post-content-myCPT.php’ . $blog_type );
    In post-content-myCPT.php I added get_taxonomy_objects, changing line 172 from <?php kleo_entry_meta();?>
    to

    <?php function get_current_post_taxonomies(){
    global $post;
    $taxonomy_names = get_object_taxonomies( $post );
    print_r( $taxonomy_names );
    }
    add_action(‘wp_head’,’get_current_post_taxonomies’);
    ?>

    When I do so (or if I try to change in any way the get_template file addres) the only result is that my archive page can’t load posts anymore. I think there must be something in the Kleo framework I am not getting. Could you please be so kind and help me out with this one?
    Thanks in advance.

    #79331
     sharmstr
    Moderator

    To add your custom categories/taxonomies, read this: https://archived.seventhqueen.com/forums/topic/custom-post-type-meta-not-showing-on-single-posts-and-post-archieves#post-59185

    This is wrong

    COPY CODE
    
    get_template_part( ‘/post-content-myCPT.php’ . $blog_type );
    

    basically you’ve just told it to open a file called /post-content-myCPT.phpmasonry or /post-content-myCPT.phpstandard

    First, you dont add .php to get_template_part calls. Its assumed. Second, since you only copied the masonry layout, adding $blog_type makes no sense. All you need is

    COPY CODE
    
    get_template_part( '/post-content-myCPT' );
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #79570
     raniele
    Participant

    Thanks Sharmstr,
    both for the code and for the directions.
    It worked smoothly and hopefully I could learn something, really appreciated your help and your sharing.
    There is just one more thing I can’t figure out and I would like to ask your kind your help with:
    What if I want to show more than one hyerarchical taxonomy through kleo_entry_meta?
    It seems I am just not able to dublicate get_the_term_list
    Thanks in advance for your time.

    #79573
     sharmstr
    Moderator

    If I’m understanding you correctly, you just need to do multiple get_the_term_list calls. So for taxes related to a Movies custom post type….

    COPY CODE
    
    if (get_post_type() == 'movies') {
    	$categories_list .= get_the_term_list( $post->ID, 'genre', '', ', ' );
    	$categories_list .= ', ';
    	$categories_list .= get_the_term_list( $post->ID, 'rating', '', ', ' );
    } else {
    	// Translators: used between list items, there is a space after the comma.
    	if ( in_array( 'categories', $meta_elements ) ) {
    	$categories_list = get_the_category_list(__(', ', 'kleo_framework'));
    	}
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #80202
     raniele
    Participant

    Timely and awsome! Thanks a lot!

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?