• Hello!

    On the customizer i have hidden author & category, only displaying post-date on posts. However on my custom posts no meta information are shown at all. How can i fix so the post date are shown on my custom posts “recipes” as well?

    Thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello,

    Add the code below to the functions.php file of the OceanWP child theme and check it works or not? or go to the oceanwp/partials/entry folder and copy the meta.php file in your child theme, then edit it for your CPT purpose.

    function OWP_CPT_entry_meta() {
    
        global $post;
        if ($post->post_type == "Your Custom Post Type") {
          ?>
    
          <ul class="meta clr">
    
                <li class="meta-author"<?php oceanwp_schema_markup( 'author_name' ); ?>><i class="icon-user"></i><?php echo the_author_posts_link(); ?></li>
    
                <li class="meta-date"<?php oceanwp_schema_markup( 'publish_date' ); ?>><i class="icon-clock"></i><?php echo get_the_date(); ?></li>
    
                <li class="meta-cat"><i class="icon-folder"></i><?php the_category( ' / ', get_the_ID() ); ?></li>
    
                <li class="meta-comments"><i class="icon-bubble"></i><?php comments_popup_link( esc_html__( '0 Comments', 'oceanwp' ), esc_html__( '1 Comment',  'oceanwp' ), esc_html__( '% Comments', 'oceanwp' ), 'comments-link' ); ?></li>
    
          </ul>
    
          <?php
        }
    
    }
    add_filter('ocean_blog_entry_meta','OWP_CPT_entry_meta');
    
    function OWP_CPT_single_meta() {
    
        global $post;
        if ($post->post_type == "Your Custom Post Type") {
          ?>
    
          <ul class="meta clr">
    
                <li class="meta-author"<?php oceanwp_schema_markup( 'author_name' ); ?>><i class="icon-user"></i><?php echo the_author_posts_link(); ?></li>
    
                <li class="meta-date"<?php oceanwp_schema_markup( 'publish_date' ); ?>><i class="icon-clock"></i><?php echo get_the_date(); ?></li>
    
                <li class="meta-cat"><i class="icon-folder"></i><?php the_category( ' / ', get_the_ID() ); ?></li>
    
                <li class="meta-comments"><i class="icon-bubble"></i><?php comments_popup_link( esc_html__( '0 Comments', 'oceanwp' ), esc_html__( '1 Comment',  'oceanwp' ), esc_html__( '% Comments', 'oceanwp' ), 'comments-link' ); ?></li>
    
          </ul>
    
          <?php
        }
    
    }
    add_filter('ocean_blog_single_meta','OWP_CPT_single_meta');
    Thread Starter testarn

    (@testarn)

    @apprimit Great, thank you! If i have more custom posts do i have to add all that code below each other or is it possible to add more custom posts in that code itself? sadly i dont know any php at all :/

    Hi,

    You can try something like this. Let me know it works or not. Update the above code with this line.

    if ($post->post_type == array('custom post1', 'custom post2', 'custom post3'))

    Thread Starter testarn

    (@testarn)

    Hi!

    That code did not appear to be working. Neither of the meta boxes on the custom posts appears with the array code.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @apprimit @oceanwp I’ve deleted your offer to login to your user’s site. I’m am 100% sure you mean well but please never ask for credentials on these forums.

    https://www.ads-software.com/support/guidelines/#the-bad-stuff

    Now for the why: The internet is a wonderful place full of very nice people and a few very bad ones. I’m sure everyone here is very nice however, by giving some ones keys to your house you are trusting they wont steal anything. Likewise the person who takes the keys is now responsible for the house FOREVER.

    If something was to go wrong, then you the author may well legally become liable for damages, which they would not normally have been as their software is provided without warranty.

    Please be aware that repeatedly asking for credentials will result in us asking you to repeatedly stop before escalating up to the plugins team.

    @jdembowski sorry for the mistake. I’ll never ask again. Can you please fix my account so that I can reply to the topic? Currently, I’m seeing a yellow box after replying – ‘This post has been held for moderation by our automated system and will be manually reviewed by a moderator.’

    Geoffrey Shilling

    (@geoffreyshilling)

    Volunteer Moderator

    @apprimit For now, go ahead and do things the right way, keeping in mind the feedback that was provided to you above. Once you show you understand and are following that, the moderation will be removed from your account.

    Thread Starter testarn

    (@testarn)

    Um… Well since this is my thread, this is not solved yet with different custom posts in that same code. I guess i have to use the function twice or three times then for more custom posts?

    @geoffreyshilling Thank you!

    if (get_post_type() == 'custom_post_type_1' || get_post_type() == 'custom_post_type_2' || get_post_type() == 'custom_post_type_3') {

    or

    $cpt = array('custom_post_type_1', 'custom_post_type_2', 'custom_post_type_3');
    	if (in_array(get_post_type(), $cpt)) {
    • This reply was modified 5 years, 7 months ago by flashfreak8. Reason: cleaner code
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Meta info on custom posts’ is closed to new replies.