Tagged: x
-
AuthorPosts
-
April 4, 2016 at 6:18 pm #866756
Amma1ParticipantHi,
I was wondering if it were possible to have the post categories showing above the post title (but still below the featured image) on single posts?
I want the top of my posts to be like this:
– Featured Image
– Post Categories
– Post Title
– Post Date
– Post ContentI’ve managed to get the date to display with a shortcode but I’m not sure what to add to wp-single.php to get it to run the date after the title but before the content but am not sure how to get it to show the categories above the title. Perhaps there is a way for it to display the meta above the post title and then disable everything in the meta except the categories?
I’m using a child theme with the integrity stack btw 🙂
Thanks
Rob
April 5, 2016 at 3:19 am #867282
ChristopherModeratorThanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. 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 with everything.
April 6, 2016 at 8:54 pm #870383
Amma1ParticipantThis reply has been marked as private.April 7, 2016 at 2:55 am #870722
RadModeratorHi there,
Hmm, that would be tricky since your post date is manually added to the content. Why not just enable post meta through customizer then customize its code?
You can enable it at Admin > Appearance > Customizer > Blog > CONTENT > Post Meta, then we can just re-arrange the order of post meta through coding. Let me know.
Thanks!
April 7, 2016 at 5:30 pm #872016
Amma1ParticipantAh, ok yes I have turned this on now. Could you tell me how to rearrange the meta (I only want the categories)
Thanks
April 8, 2016 at 5:55 am #872626
Paul RModeratorHi,
To achieve that, you can add this in your child theme’s functions.php file.
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: “%s”", '__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: “%s”", '__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: “%s”', '__x__' ), $title ) ), $text ); } else { $comments = ''; } // // Output. // if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%s</p>', $categories_list ); } }Hope that helps.
April 10, 2016 at 8:05 pm #875738
Amma1ParticipantHi,
Thanks, thats only showing the categories now. The only thing now is that it is still displaying below the post title whereas I would like it to appear above the post title?
Thanks
April 11, 2016 at 4:23 am #876151
Rue NelModeratorHello There,
To display the post meta or categories above your post titles, since you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file<?php // ============================================================================= // VIEWS/INTEGRITY/_CONTENT-POST-HEADER.PHP // ----------------------------------------------------------------------------- // Standard <header> output for various posts. // ============================================================================= ?> <header class="entry-header"> <?php x_integrity_entry_meta(); ?> <?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; ?> </header>3] Save the file named as
_content-post-header.php
4] Upload this file to your server in the child theme’s folder
wp-content/themes/x-child/framework/views/integrity/Please let us know if this works out for you.
April 11, 2016 at 4:18 pm #877188
Amma1ParticipantAh! that’s great 🙂
How can I remove the commas between the categories?
Thanks
Rob
April 12, 2016 at 3:04 am #877847
LelyModeratorHello Rob,
Please update the code suggested above on reply #872626.
Look for this line of code:
$separator = ', ';
Update to this:
$separator = ' ';
It is below this line:
$categories = get_the_terms( get_the_ID(), 'portfolio-category' );Hope this helps.
April 12, 2016 at 7:47 am #878184
Amma1ParticipantGreat, thanks!
April 12, 2016 at 12:19 pm #878651
Prasant RaiModeratorYou are most welcome.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-866756 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
