Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #897291
    Alex
    Participant

    Hello,

    who can I hide the author and category in posts and modify the size and color of the publish date.
    Also I need to add a custom Field.

    Thank you very much!

    Regards,
    Alex

    #898055
    Lely
    Moderator

    Hi Alex,

    Thanks for posting in. Please add the following CSS in Customizer’s > Custom CSS:

    p.p-meta span:first-of-type {
        display: none;
    }
    p.p-meta span + span {
        color: red;  /*Change to your preferred color*/
        font-size: 20px; /* Change to your preferred font size*/
    }
    

    Please do share us your site URL if this doesn’t work.

    To add custom field, please click Screen Option from the upper right part of the page. Check custom field. Then on the lower part the option for this will open. See attached screenshots.

    Always,
    X

    #898380
    Alex
    Participant

    Okay,

    how can I hide the Category
    and how can I make a custom field visible at the postlist?

    Thank you very much!

    Regards
    Alex

    #898939
    Rupok
    Member

    Hi Alex,

    Kindly share your URL so that we could check and give you some tailored code.

    Cheers!

    #899251
    Alex
    Participant
    This reply has been marked as private.
    #900182
    Paul R
    Moderator

    Hi,

    Thank you for providing your login credentials.

    I went ahead and added this code in your child theme’s functions.php file to remove author and category.

    
      function x_integrity_entry_meta() {
    
        //
        // Author.
        //
    
        $author = sprintf( '<span><i class="x-icon-pencil" data-x-icon=""></i> %s</span>',
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon=""></i> %2$s</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() )
        );
    
        //
        // Categories.
        //
    
        if ( get_post_type() == 'x-portfolio' ) {
          if ( has_term( '', 'portfolio-category', NULL ) ) {
            $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
            $separator         = ', ';
            $categories_output = '';
            foreach ( $categories as $category ) {
              $categories_output .= '<a href="'
                                  . get_term_link( $category->slug, 'portfolio-category' )
                                  . '" title="'
                                  . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                  . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                  . $category->name
                                  . '</a>'
                                  . $separator;
            }
    
            $categories_list = sprintf( '<span>%s</span>',
              trim( $categories_output, $separator )
            );
          } else {
            $categories_list = '';
          }
        } else {
          $categories        = get_the_category();
          $separator         = ', ';
          $categories_output = '';
          foreach ( $categories as $category ) {
            $categories_output .= '<a href="'
                                . get_category_link( $category->term_id )
                                . '" title="'
                                . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                . $category->name
                                . '</a>'
                                . $separator;
          }
    
          $categories_list = sprintf( '<span>%s</span>',
            trim( $categories_output, $separator )
          );
        }
    
        //
        // Comments link.
        //
    
        if ( comments_open() ) {
    
          $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
          $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
          $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
    
          if ( $number == 0 ) {
            $text = __( 'Leave a Comment' , '__x__' );
          } else if ( $number == 1 ) {
            $text = $number . ' ' . __( 'Comment' , '__x__' );
          } else {
            $text = $number . ' ' . __( 'Comments' , '__x__' );
          }
    
          $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon=""></i> %3$s</a></span>',
            esc_url( $link ),
            esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
            $text
          );
    
        } else {
    
          $comments = '';
    
        }
    
        //
        // Output.
        //
    
        if ( x_does_not_need_entry_meta() ) {
          return;
        } else {
          printf( '<p class="p-meta">%1$s%2$s</p>',   
            $date,       
            $comments
          );
        }
    
      }
    

    With regards to custom field, can you specify what kind of data you want to add.

    Thanks

    #900184
    Alex
    Participant

    Hello,

    thank you very much!
    I want to add a custom field (created with Advanced Custom Fields) called “eintritt”.

    Cheers,
    Alex

    #901524
    Paul R
    Moderator

    Hi Alex,

    To display it, you can use this code to display custom field.

    
    <?php echo get_post_meta($post->ID, 'eintritt', true); ?>
    

    eg.

    
    
      function x_integrity_entry_meta() {
       Global $post;
        //
        // Author.
        //
    
        $author = sprintf( '<span><i class="x-icon-pencil" data-x-icon=""></i> %s</span>',
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon=""></i> %2$s</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() )
        );
    
        //
        // Categories.
        //
    
        if ( get_post_type() == 'x-portfolio' ) {
          if ( has_term( '', 'portfolio-category', NULL ) ) {
            $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
            $separator         = ', ';
            $categories_output = '';
            foreach ( $categories as $category ) {
              $categories_output .= '<a href="'
                                  . get_term_link( $category->slug, 'portfolio-category' )
                                  . '" title="'
                                  . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                  . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                  . $category->name
                                  . '</a>'
                                  . $separator;
            }
    
            $categories_list = sprintf( '<span>%s</span>',
              trim( $categories_output, $separator )
            );
          } else {
            $categories_list = '';
          }
        } else {
          $categories        = get_the_category();
          $separator         = ', ';
          $categories_output = '';
          foreach ( $categories as $category ) {
            $categories_output .= '<a href="'
                                . get_category_link( $category->term_id )
                                . '" title="'
                                . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                . $category->name
                                . '</a>'
                                . $separator;
          }
    
          $categories_list = sprintf( '<span>%s</span>',
            trim( $categories_output, $separator )
          );
        }
    
        //
        // Comments link.
        //
    
        if ( comments_open() ) {
    
          $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
          $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
          $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
    
          if ( $number == 0 ) {
            $text = __( 'Leave a Comment' , '__x__' );
          } else if ( $number == 1 ) {
            $text = $number . ' ' . __( 'Comment' , '__x__' );
          } else {
            $text = $number . ' ' . __( 'Comments' , '__x__' );
          }
    
          $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon=""></i> %3$s</a></span>',
            esc_url( $link ),
            esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
            $text
          );
    
        } else {
    
          $comments = '';
    
        }
    
        //
        // Output.
        //
    
        if ( x_does_not_need_entry_meta() ) {
          return;
        } else {
          printf( '<p class="p-meta">%1$s%2$s %3$s</p>',   
            $date,       
            $comments,
            get_post_meta($post->ID, 'eintritt', true)
          );
        }
    
      }
    

    Hope that helps.

    #901579
    Alex
    Participant

    Can I add this code to the function.php of the Child Theme?

    #902515
    Jade
    Moderator

    Hi there,

    Yes, you can simply modify the code we have added on our previous response which is in the functions.php file. 🙂

    #904079
    Alex
    Participant

    okay.

    and where have I to enter this code?

    <?php echo get_post_meta($post->ID, 'eintritt', true); ?>

    Sorry for all that silly questions 🙂

    Thank you very much!

    Regards,
    Alex

    #905052
    Rue Nel
    Moderator

    Hey Alex,

    The complete code is already given here:
    https://community.theme.co/forums/topic/posts-hide-author-scale-date-add-custom-field/#post-901524

    Please let us know how it goes.

    #987352
    Alex
    Participant

    Yes.
    You gave me 2 code parts.

    I have to put the second part into the functions.php
    But where do I have to put the first part?

    #987405
    Lely
    Moderator

    Hello There,

    The first part was already added on the second part of the code at the bottom. Please check attached screenshot.

  • <script> jQuery(function($){ $("#no-reply-897291 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>