Community Forums › Forums › Archived Forums › Design Tips and Tricks › Post excerpt appearing twice on homepage but only once on category.
- This topic has 2 replies, 2 voices, and was last updated 10 years, 8 months ago by
verti.
-
AuthorPosts
-
June 10, 2014 at 2:28 am #108726
verti
MemberHi, i have added a bit of code to functions.php(minimum pro child theme) to change to a masonry layout with the following code.
// ================================================================= // = Pinterest-like Masonry layout for Posts page and Archives = // ================================================================= //* Enqueue and initialize jQuery Masonry script function sk_masonry_script() { if (is_home() || is_archive()) { wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js' , array( 'jquery-masonry' ), '1.0', true ); //* Infinite Scroll //wp_enqueue_script( 'infinite-scroll', get_stylesheet_directory_uri().'/js/jquery.infinitescroll.min.js' , array('jquery'), '1.0', true ); //wp_enqueue_script( 'infinite-scroll-init', get_stylesheet_directory_uri().'/js/infinitescroll-init.js' , array('jquery'), '1.0', true ); } } add_action( 'wp_enqueue_scripts', 'sk_masonry_script' ); //* Add custom body class to the head add_filter( 'body_class', 'sk_body_class' ); function sk_body_class( $classes ) { if (is_home()||is_archive()) $classes[] = 'masonry-page'; return $classes; } //* Display Post thumbnail, Post title, Post content/excerpt, Post info and Post meta in masonry brick add_action('genesis_meta','sk_masonry_layout'); function sk_masonry_layout() { if (is_home()||is_archive()) { //add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); add_action( 'genesis_entry_content', 'sk_masonry_block_post_image', 8 ) ; add_action( 'genesis_entry_content', 'sk_masonry_title_content', 9 ); //add_action( 'genesis_entry_footer', 'sk_masonry_entry_footer' ); remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); //add_action( 'genesis_before_content', 'genesis_do_breadcrumbs' ); remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); //add_action( 'genesis_before_content', 'genesis_do_taxonomy_title_description', 15 ); remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 ); //add_action( 'genesis_before_content', 'genesis_do_author_title_description', 15 ); remove_action( 'genesis_before_loop', 'genesis_do_author_box_archive', 15 ); //add_action( 'genesis_before_content', 'genesis_do_author_box_archive', 15 ); remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' ); //add_action( 'genesis_before_content', 'genesis_do_cpt_archive_title_description' ); remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' ); //add_action( 'genesis_after_content', 'genesis_posts_nav' ); } } //* Helper function to display Post title and Post content/excerpt wrapped in a custom div function sk_masonry_title_content() { echo '<div class="title-content">'; genesis_do_post_title(); genesis_do_post_content(); echo '</div>'; } //* Helper function to display Post info and Post meta function sk_masonry_entry_footer() { genesis_post_info(); genesis_post_meta(); } //* Set the second parameter to width of your masonry brick (.home .entry, .archive .entry) add_image_size( 'masonry-brick-image', 233, 0, TRUE ); //* Helper function to display featured image //* Source: http://surefirewebservices.com/development/genesis-framework/using-the-genesis-featured-image function sk_masonry_block_post_image() { $img = genesis_get_image( array( 'format' => 'html', 'size' => 'masonry-brick-image', 'attr' => array( 'class' => 'post-image' ) ) ); printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $img ); } //* Add more link when using excerpts function sk_excerpt_more($more) { return '<a class="more-link" href="'. get_permalink() . '"> [Continue Reading]</a>'; } add_filter('excerpt_more', 'sk_excerpt_more'); //* Modify the length of post excerpts add_filter( 'excerpt_length', 'sk_excerpt_length' ); function sk_excerpt_length( $length ) { return 10; // pull first 10 words }
my url is http://www.propertiesnewlaunch.sg/ where you can see the difference between homepage and when you click on all category.
June 10, 2014 at 7:07 am #108752Lauren @ OnceCoupled
MemberThe content is being called twice on your home page, because of your masonry code and the fact that you're using Genesis Grid Loop.
This function:
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
does not work with the Genesis Grid Loop, so when you call:genesis_do_post_content();
later, it's being duplicated.Try removing that call for the post content, and styling the default content block, or not using the genesis grid loop on your home page.
Best,
Lauren
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
June 12, 2014 at 2:12 am #109444verti
MemberI see, thanks for the information, issue solved now
Regards
Joe -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.