-
AuthorPosts
-
April 8, 2015 at 6:29 am #244581
Hi there,
I’m experiencing an unusual problem. I’m using the ICON stack and although I’ve not altered the meta informations settings for posts and portfolios, my portfolio items are displaying a date stamp but not author, whereas my blog posts are not displaying any meta information.
I would like the following situation:
Blog Posts: Date, author, tags
Portfolio items: No date, no authorPlease can you let me know how I can achieve the above?
Many thanks,
Melissa
April 8, 2015 at 7:19 am #244619Hi there,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Please add this in functions.php file inside child theme :
// Entry Meta // ============================================================================= if ( ! function_exists( 'x_icon_entry_meta' ) ) : function x_icon_entry_meta() { $author = sprintf( '<span><i class="x-icon-pencil"></i> %s</span>', get_the_author() ); $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar"></i> %2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); 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: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark"></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: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark"></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } if ( comments_open() ) { $title = get_the_title(); $link = get_comments_link(); $number = get_comments_number(); if ( $number == 0 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), __( 'Leave a Comment' , '__x__' ) ); } else if ( $number == 1 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comment' , '__x__' ) ); } else { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comments' , '__x__' ) ); } } else { $comments = ''; } if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>', $author, $date, $categories_list, $comments ); } } endif;
To display tags copy _content-post-headerx.php file from framework -> views -> icon and put it in the same path inside child theme, Now replace existing code with this:
<?php // ============================================================================= // VIEWS/ICON/_CONTENT-POST-HEADER.PHP // ----------------------------------------------------------------------------- // Standard <header> output for various posts. // ============================================================================= ?> <header class="entry-header"> <?php if ( is_single() ) : ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php else : ?> <h2 class="entry-title"> <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php x_the_alternate_title(); ?></a> </h2> <?php endif; ?> <?php x_icon_entry_meta(); ?> <?php if ( has_tag() ) : ?> <footer class="entry-footer cf"> <?php echo get_the_tag_list(); ?> </footer> <?php endif; ?> <?php if ( get_post_format() == 'quote' ) : ?> <p class="entry-title-sub"><?php echo get_post_meta( get_the_ID(), '_x_quote_quote', true ); ?></p> <?php endif; ?> </header>
Please add the following CSS under Customize -> Custom -> CSS :`
.single-x-portfolio .p-meta{ display:none; }
Hope it helps.
April 14, 2015 at 11:08 am #249417Many thanks for your help. I created the child theme (I had one already) and copied the above code into my functions.php file in the x child theme. The portfolio items are now all correct, I can only see the title and no author or date information – great! However, there is also no meta information showing for blog posts – I would like to see date and author here if possible…
Regards,
Melissa
April 14, 2015 at 12:35 pm #249507Hi There,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / Password
Don’t forget to select Set as a private reply. This ensures your information is only visible to our staff.April 23, 2015 at 10:38 am #256730Hi there,
I think I mentioned in a previous post that I am developing offline, so don’t have an URL or credentials I can send you, but happy to send you the code. Here is my functions.php file:
<?php
// =============================================================================
// FUNCTIONS.PHP
// —————————————————————————–
// Overwrite or add your own custom functions to X in this file.
// =============================================================================
// Entry Meta
// =============================================================================if ( ! function_exists( ‘x_icon_entry_meta’ ) ) :
function x_icon_entry_meta() {$author = sprintf( ‘<span><i class=”x-icon-pencil”></i> %s</span>’,
get_the_author()
);$date = sprintf( ‘<span><time class=”entry-date” datetime=”%1$s”><i class=”x-icon-calendar”></i> %2$s</time></span>’,
esc_attr( get_the_date( ‘c’ ) ),
esc_html( get_the_date() )
);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: “%s””, ‘__x__’ ), $category->name ) )
. ‘”><i class=”x-icon-bookmark”></i> ‘
. $category->name
. ‘‘
. $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: “%s””, ‘__x__’ ), $category->name ) )
. ‘”><i class=”x-icon-bookmark”></i> ‘
. $category->name
. ‘‘
. $separator;
}$categories_list = sprintf( ‘<span>%s</span>’,
trim( $categories_output, $separator )
);
}if ( comments_open() ) {
$title = get_the_title();
$link = get_comments_link();
$number = get_comments_number();
if ( $number == 0 ) {
$comments = sprintf( ‘<span><i class=”x-icon-comments”></i> %3$s</span>’,
esc_url( $link ),
esc_attr( sprintf( __( ‘Leave a comment on: “%s”’, ‘__x__’ ), $title ) ),
__( ‘Leave a Comment’ , ‘__x__’ )
);
} else if ( $number == 1 ) {
$comments = sprintf( ‘<span><i class=”x-icon-comments”></i> %3$s</span>’,
esc_url( $link ),
esc_attr( sprintf( __( ‘Leave a comment on: “%s”’, ‘__x__’ ), $title ) ),
$number . ‘ ‘ . __( ‘Comment’ , ‘__x__’ )
);
} else {
$comments = sprintf( ‘<span><i class=”x-icon-comments”></i> %3$s</span>’,
esc_url( $link ),
esc_attr( sprintf( __( ‘Leave a comment on: “%s”’, ‘__x__’ ), $title ) ),
$number . ‘ ‘ . __( ‘Comments’ , ‘__x__’ )
);
}
} else {
$comments = ”;
}if ( x_does_not_need_entry_meta() ) {
return;
} else {
printf( ‘<p class=”p-meta”>%1$s%2$s%3$s%4$s</p>’,
$author,
$date,
$categories_list,
$comments
);
}}
endif;?>
April 23, 2015 at 2:41 pm #256898Hello There,
Thanks for writing in.
Please check Appearance > Customize > Blog > Post Meta if it is enabled. If not, please enable it.
Thanks.
May 5, 2015 at 8:09 am #265872Yes that was the issue – very straightforward. Thanks for your help!
How do I alter the functions.php code if I now want to display only the date and author using the “|” separator? (NO tags and NO icons)Is there a global setting to turn off icons through the site?
Many thanks,
Melissa
May 5, 2015 at 10:16 am #266010Hi Melissa,
Thanks for writing in! To assist you with this, we’ll first need you to provide us with your URL as stated on the forum entrance page. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you.
In the meantime, to disable the post icons, you can use following CSS under Custom > CSS in the Customizer:
.entry-title:before { display: none; }
Thanks!
-
AuthorPosts