Customise meta in portfolio

I’m using the Renew stack. When I’m on a single portfolio item page the only meta info I want to display is the tags. It seems I need to change some code in the template, specifically line 40 of

…/wp-content/themes/x/framework/views/renew/content-portfolio.php

which reads

<?php x_renew_entry_meta(); ?>

What should I change this to so it only displays the tags and not the author or date?
Or is there a better way to get the same result?

Thanks

Hi There,

Go to this file: ../wp-content/themes/x/framework/functions/renew.php
x_renew_entry_meta(); function is define on that file. Copy the entire function, that is from line 20 to line 132 of that file to your child theme’s functions.php file.
Update the following part to display what you want.

      printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
        $author,
        $date,
        $categories_list,
        $comments
      );

See this guide: http://php.net/manual/en/function.printf.php

Hope this helps.

Thanks, Lely.

I only want to change the meta in the portfolio not the blog. If I make this change, will it also affect the meta in the blog?

Correct. Which meta do you want to change?

You can use the if( x_is_portfolio_item() ) condition to make it work for portfolio items only.

Regards!

Thanks, thai.

I’ve done what Lely said and that has worked.

I’m completely inexperienced with PHP. Could you explain or show me where to put the if( x_is_portfolio_item() ) condition in my functions.php file?

Hi there,

You can add it below the last code that is currently in the functions.php file.

If you haven’t made any changes to the file yet, place the code after:

// Additional Functions
// =============================================================================

Hope this helps.

The thing I need to know is how to use if( x_is_portfolio_item() ) condition in relation to the entire if ( ! function_exists( 'x_renew_entry_meta' ) ) function that I’ve added to functions.php.

If i just add if( x_is_portfolio_item() ) below the last code in functions.php, I get the following message when I try to load the page: “Parse error: syntax error, unexpected end of file in /home4/jeffgill/public_html/vellerosus.com/wp-content/themes/x-child/functions.php on line 137”

Hi,

The entire should like this.

function x_renew_entry_meta() {

    //
    // Author.
    //

    $author = sprintf( '<span>%s</span>',
      get_the_author()
    );


    //
    // Date.
    //

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%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 ) )
                              . '"> '
                              . $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 ) )
                            . '">'
                            . $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() );


	  $text = ( 0 == $number ) ? __( 'Leave a Comment', '__x__' ) : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );


	  $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%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 {
     if( x_is_portfolio_item() ) {
         printf( '<p class="p-meta">%s</p>',        
             $categories_list      
         );
     }   else {
         printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
           $author,
           $date,
           $categories_list,
           $comments
         );
     }
    }

  }

Thanks

Perfect! Thank you so much, paul.r.
Job done.

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.