Tagged: x
-
AuthorPosts
-
July 12, 2016 at 10:15 pm #1084159
MBParticipantHi,
We would like new code snippet to add to function.php file in child theme folder please.
1. Post meta date = published to last updated
2. Blog order = published to last updatedThanks, MB
July 13, 2016 at 5:02 am #1084585
ChristianModeratorHey there,
1. Please add the code below in your functions.php
function x_ethos_entry_meta() { // // Author. // $author = sprintf( ' %1$s %2$s</span>', __( 'by', '__x__' ), get_the_author() ); // // Date. // $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>', esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_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 ) ) . '"> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%1$s %2$s', __( 'In', '__x__' ), 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 ) ) . '"> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%1$s %2$s', __( 'In', '__x__' ), 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' : 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: “%s”', '__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%4$s</p>', $categories_list, $author, $date, $comments ); } }2. This requires template change. Copy _index.php located in x\framework\views\ethos to the same folder in your child theme x-child\framework\views\ethos. Open the copied file and go to line 42 or the line
$wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => $category->term_id ) );Change it to
$wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => $category->term_id, 'orderby' => 'modified' ) );Hope that helps. 🙂
July 13, 2016 at 8:04 am #1084810
MBParticipantHi,
Thanks for your reply.
1. We added suggested code and it changed single post meta to last modified date. How do we change the front page and archive meta to last modified date? How do we change to last modified date to show in the Google SERP meta?
2. We will make template change and let you know how it works.
Thanks, MB
July 13, 2016 at 7:54 pm #1085941
Rue NelModeratorHello There,
Thanks for the updates! By default WordPress will display the posts in chronological order. The last published date will be displayed first. If you change the order, you must alter the WP_Query which you already did. Christopher also suggested some changes in your query. I would highly suggest that you review the way you have altered the query to avoid any further conflict sooner or later. Please do review this article here:
http://presscustomizr.com/snippet/three-techniques-to-alter-the-query-in-wordpress/Moreover, once you have successfully have all the changes for your site, you will need to ask the Google bots to re index your site so that the latest version of your pages along with the last updated dates will be displayed in Google search results. Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.
Thank you for your understanding.
July 13, 2016 at 9:18 pm #1086080
MBParticipantCan you please provide a solution to hide the entry meta on front page and archive pages?
That ought to be a simple solution and we will not end to alter the chronological order of the posts.
We will use the ethos post slider to feature the last updated post.
Thanks, MB
July 14, 2016 at 3:31 am #1086420
RadModeratorHi there,
From the provided code above, please change this line,
if ( x_does_not_need_entry_meta() ) {to this
if ( x_does_not_need_entry_meta() || is_home() || is_archive() || is_front_page() ) {Hope this helps.
July 14, 2016 at 1:01 pm #1087206
MBParticipantHi,
We updated our blog layout in Customizer to masonry style.
We have solved the display last update instead of published date on single posts meta.
We would like to hide the published date meta on the featured post slider. And keep the category meta. Is this achievable?
Thanks, MB
July 14, 2016 at 5:52 pm #1087558
JadeModeratorHi there,
Please create a file named _post-slider.php in x-child\framework\views\ethos then add this code in the file:
<?php // ============================================================================= // VIEWS/ETHOS/_POST-SLIDER.PHP // ----------------------------------------------------------------------------- // Outputs the post slider that appears at the top of the blog. // ============================================================================= $is_blog = is_home(); $is_archive = is_category() || is_tag(); if ( $is_blog || $is_archive ) : if ( $is_blog ) { $info = array( 'blog', NULL, NULL, '_x_ethos_post_slider_blog_display' ); } elseif ( $is_archive ) { $type = ( is_category() ) ? 'cat' : 'tag_id'; $info = array( 'archive', $type, get_queried_object_id(), '_x_ethos_post_slider_archives_display' ); } $slider_enabled = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_enable' ) == '1'; $count = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_count' ); $display = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_display' ); $blog_slider_is_enabled = $slider_enabled && $is_blog; $archive_slider_is_enabled = $slider_enabled && $is_archive; $is_enabled = $blog_slider_is_enabled || $archive_slider_is_enabled; switch ( $display ) { case 'most-commented' : $args = array( 'post_type' => 'post', 'posts_per_page' => $count, 'orderby' => 'comment_count', 'order' => 'DESC', $info[1] => $info[2] ); break; case 'random' : $args = array( 'post_type' => 'post', 'posts_per_page' => $count, 'orderby' => 'rand', $info[1] => $info[2] ); break; case 'featured' : $args = array( 'post_type' => 'post', 'posts_per_page' => $count, 'orderby' => 'date', 'meta_key' => $info[3], 'meta_value' => 'on', 'ignore_sticky_posts' => true ); break; } ?> <?php if ( $is_enabled ) : ?> <div class="x-flexslider x-post-slider"> <ul class="x-slides"> <?php $wp_query = new WP_Query( $args ); ?> <?php if ( $wp_query->have_posts() ) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <li class="x-slide"> <article <?php post_class( 'x-post-slider-entry' ); ?> style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> <a href="<?php the_permalink(); ?>"> <div class="cover"> <div class="middle"> <span class="featured-meta"><?php echo x_ethos_post_categories(); ?></span> <h2 class="h-featured"><span><?php x_the_alternate_title(); ?></span></h2> <span class="featured-view"><?php _e( 'View Post', '__x__' ); ?></span> </div> </div> </a> </article> </li> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?> </ul> </div> <script> jQuery(window).load(function() { jQuery('.x-post-slider').flexslider({ controlNav : false, selector : '.x-slides > li', prevText : '<i class="x-icon-chevron-left" data-x-icon=""></i>', nextText : '<i class="x-icon-chevron-right" data-x-icon=""></i>', animation : 'fade', smoothHeight : true, slideshow : true }); }); </script> <?php endif; ?> <?php endif; ?>Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1084159 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
