- This topic has 13 replies, 4 voices, and was last updated 4 years, 11 months ago by David.
-
AuthorPosts
-
April 26, 2019 at 6:16 pm #881034Steig
Hello,
On the post archive page, which is my home page, I have the content type set to excerpt with 20 word count.
When the words exceed this figure, three dots and then the words Read more are appended.
Can the hyperlink for “read more” be removed?
In fact, what I’d like is for the entire post excerpt to be clickable. Right now just the post title is. That is done through PHP in the content.php file
<?php /** * The template for displaying posts within the loop. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>> <div class="inside-article"> <?php /** * generate_before_content hook. * * @since 0.1 * * @hooked generate_featured_page_header_inside_single - 10 */ do_action( 'generate_before_content' ); ?> <header class="entry-header"> <?php /** * generate_before_entry_title hook. * * @since 0.1 */ do_action( 'generate_before_entry_title' ); the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); /** * generate_after_entry_title hook. * * @since 0.1 * * @hooked generate_post_meta - 10 */ do_action( 'generate_after_entry_title' ); ?> </header><!-- .entry-header --> <?php /** * generate_after_entry_header hook. * * @since 0.1 * * @hooked generate_post_image - 10 */ do_action( 'generate_after_entry_header' ); if ( generate_show_excerpt() ) : ?> <div class="entry-summary" itemprop="text"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content" itemprop="text"> <?php the_content(); wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ), 'after' => '</div>', ) ); ?> </div><!-- .entry-content --> <?php endif; /** * generate_after_entry_content hook. * * @since 0.1 * * @hooked generate_footer_meta - 10 */ do_action( 'generate_after_entry_content' ); /** * generate_after_content hook. * * @since 0.1 */ do_action( 'generate_after_content' ); ?> </div><!-- .inside-article --> </article><!-- #post-## -->
Could you tell me how to make the entire excerpt clickable so I can trigger this popup?
Thanks
April 26, 2019 at 8:49 pm #881091LeoStaffCustomer SupportHi there,
Have you tried using the customizer option to remove the read more tag?
https://docs.generatepress.com/article/blog-content-layout/As to make the excerpt clickable, this might help:
https://generatepress.com/forums/topic/how-to-link-excerpt-field-to-post/#post-789097April 27, 2019 at 6:01 am #881338SteigI’ve edited the footer.php file as follows. I get an error message on line 44, which is the row where <script> is
<?php /** * The template for displaying the footer. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> </div><!-- #content --> </div><!-- #page --> <?php /** * generate_before_footer hook. * * @since 0.1 */ do_action( 'generate_before_footer' ); ?> <div <?php generate_do_element_classes( 'footer' ); ?>> <?php /** * generate_before_footer_content hook. * * @since 0.1 */ do_action( 'generate_before_footer_content' ); /** * generate_footer hook. * * @since 1.3.42 * * @hooked generate_construct_footer_widgets - 5 * @hooked generate_construct_footer - 10 */ do_action( 'generate_footer' ); <script> jQuery( document ).ready( function($) { var body = $( 'body' ); if ( body.hasClass( 'blog' ) || body.hasClass( 'archive' ) ) { $( '.type-post' ).on( 'click', function() { var link = $( this ).find( '.entry-title a' ).attr( 'href' ); if ( link ) { window.location = link; } } ); } } ); </script> /** * generate_after_footer_content hook. * * @since 0.1 */ do_action( 'generate_after_footer_content' ); ?> </div><!-- .site-footer --> <?php /** * generate_after_footer hook. * * @since 2.1 */ do_action( 'generate_after_footer' ); wp_footer(); ?> </body> </html>
April 27, 2019 at 7:42 am #881516TomLead DeveloperLead DeveloperInstead of adding that script to the footer file, use a Hook Element:
1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
2. Set the hook towp_footer
3. Add your script into the content areaLet me know ๐
April 27, 2019 at 7:56 am #881525SteigMy goal has been to make the entire excerpt clickable so it launches a pop up.
I had placed a call in the content.php file that did that for the post title only:
<header class="entry-header"> <?php /** * generate_before_entry_title hook. * * @since 0.1 */ do_action( 'generate_before_entry_title' ); the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); /** * generate_after_entry_title hook. * * @since 0.1 * * @hooked generate_post_meta - 10 */ do_action( 'generate_after_entry_title' ); ?> </header>
the relevant call is
<a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>
Could that be inserted into this wp-footer hook somehow to make the entire excerpt call this popup?
April 27, 2019 at 3:37 pm #881770TomLead DeveloperLead DeveloperIt depends on how the popup is initiated. If it’s initiated via javascript, it might be possible to initiate it when clicking the entire area instead of the
sg-iframe-popup-133
element. However, you’d need to bring this up with the popup plugin developer to know for sure.April 28, 2019 at 6:00 am #882112SteigOne thing I’ve noticed is that while the post excerpt does appear to be a single clickable area now, clicking it doesn’t do anything. I would assume it would at least take the view to the post detail page.
I removed the content.php code that caused a click to the post title to launch the popup just to see if that was causing a conflict and now a click to the post title simply now moves to the detailed post page.
How can clicking the entire excerpt container produce the same behavior?
April 28, 2019 at 8:16 am #882371TomLead DeveloperLead DeveloperDid you add the script to your site as well?: https://generatepress.com/forums/topic/making-blog-post-container-clickable/#post-602864
I’m not seeing it in your source.
Let me know ๐
April 28, 2019 at 10:38 am #882464SteigI do have that added into the Simple CSS window:
/* excerpt container is clickable with wp footer javascript */ .blog .type-post, .archive .type-post { cursor: pointer; }
When I mouse over the blog excerpt, I do have a the hand pointer cursor, but it doesn’t click to anywhere, except on the title only.
April 28, 2019 at 3:00 pm #882574TomLead DeveloperLead DeveloperYou need the other part of the code as well:
1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
2. Set the hook towp_footer
3. Add this code as the content:<script> jQuery( document ).ready( function($) { var body = $( 'body' ); if ( body.hasClass( 'blog' ) || body.hasClass( 'archive' ) ) { $( '.type-post' ).on( 'click', function() { var link = $( this ).find( '.entry-title a' ).attr( 'href' ); if ( link ) { window.location = link; } } ); } } ); </script>
Then set the Display Rules.
April 28, 2019 at 3:18 pm #882589SteigI do have that Hook element created, but realized I didn’t have a display rule set. I tried post archive and also just post and neither caused the desired effect.
April 28, 2019 at 3:26 pm #882595DavidStaffCustomer SupportTry setting your display rule to Front Page
April 28, 2019 at 4:44 pm #882618Steigsuper; thank you!
April 29, 2019 at 4:49 am #883000DavidStaffCustomer SupportGlad we could be of help.
-
AuthorPosts
- You must be logged in to reply to this topic.