-
Author
-
March 9, 2016 at 19:01 #109546michapelaParticipant
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!
March 9, 2016 at 19:25 #109557sharmstrModeratorI’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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 9, 2016 at 20:40 #109596michapelaParticipantHi 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
March 9, 2016 at 20:49 #109601sharmstrModeratorYou’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 CODEif (get_post_type() == 'projects') {
You can use the ! with that to conditionally show a meta field or not. Example with the date:
COPY CODEif (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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 9, 2016 at 21:27 #109610michapelaParticipantHi 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.
March 9, 2016 at 21:29 #109613sharmstrModeratorAh 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
March 9, 2016 at 21:30 #109614sharmstrModeratorSide 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
June 20, 2016 at 16:43 #126066StrothiParticipantDear @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 🙂
June 20, 2016 at 18:18 #126078sharmstrModeratorI 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.