This topic has 10 replies, 4 voices, and was last updated 7 years by joy.

  • Author

    Tagged: , , ,

  • #109546
     michapela
    Participant

    Hi,

    I’ve made a custom post type using the function.php in my child theme.

    Now I also copied the function kleo_entry_meta in the function.php, because I want that it shows a different meta fields than the one in the normal post.

    What should I edit in the function kleo_entry_meta??

    Thank you very much!

    #109557
     sharmstr
    Moderator

    I’ve discussed that here: https://archived.seventhqueen.com/forums/topic/custom-post-type-meta-not-showing-on-single-posts-and-post-archieves#post-59185

    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

    #109596
     michapela
    Participant

    Hi thank you for your answer.
    If I am not not wrong this was just to the categories of the CPT, but I want to to it’s to show different meta fields in each post.

    For example in my CPT just show Author Avatar, Author link and message link, and in the normal Post show Date and categories.

    So I wanted to make a custom function like kleo_entry_meta_myCPT() that only shows the meta that I want.
    Is it possible?

    Thanks

    #109601
     sharmstr
    Moderator

    You’re not saying it wrong, you just weren’t clear. Categories/Taxonomies IS meta 🙂

    Anyhow, the code is there, you just need to adapt it to suit you. If you look at the second code example, it has

    COPY CODE
    
    if (get_post_type() == 'projects') {
    

    You can use the ! with that to conditionally show a meta field or not. Example with the date:

    COPY CODE
    
    
    if (in_array( 'date', $meta_elements ) && ( !get_post_type() == 'books' ) ) {
    
    

    That codes says “If the date field exists AND this isnt a books post type, then show the date.

    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

    #109610
     michapela
    Participant

    Hi thanks, this is much more elegant solution.

    But it didn’t work properly with the ! in front get_post_type. I put it in the operator !=.

    Like this it works fine.

    #109613
     sharmstr
    Moderator

    Ah right. Sorry about that.

    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

    #109614
     sharmstr
    Moderator

    Side note: Make sure you check for changes in that function after Kleo updates.

    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

    #126066
     Strothi
    Participant

    Dear @sharmstr,

    I’ve used the code above to get rid of all my meta data, unfortunately I still end up with the “edit” link in admin mode and a corresponding meta field block in the actual cpt view. As in, as you can see here, the logo is shifted to the right, even though all meta data is hidden: https://fslci.org/universities/universite-de-bordeaux/ due to the actual meta box still showing up.

    I thought about correcting it via css, but that property applies to all posts, not just the cpt. I tried quite a lot of different ways, but I haven’t found the solution yet. I’m hiding the meta fields field by field with in my case

    if ( in_array('tags', $meta_elements ) && ( get_post_type() == '!=universities' ) ) {

    I guess there could also be a nicer way by just defining a new function for when get_post_type() == 'universities' applies, but while I’m fairly good at reading code and understand its functions, I’m not of a big code writer myself.

    Any help would be greatly appreciated!

    Thanks in advance 🙂

    #126078
     sharmstr
    Moderator

    I know longer help with support here. With that said, every post type has css class name equal to the cpt name.

    .type-universities .article-meta {
    display: none !important;
    }

    .single .with-meta .type-universities .article-media {
    margin-left: 0;
    }

    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

    #126082
     Strothi
    Participant

    Awesome!!! Thanks so much 🙂

    #155858
     joy
    Participant

    Oh no @sharmstr! Why did you leave…you were the best mod here. 🙁

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

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

Log in with your credentials

Forgot your details?