Community Forums › Forums › Archived Forums › General Discussion › How do I wrap the "read more link" in a separate paragraph for featured posts?
Tagged: add a tag, featured page, limit read more link, read more link
- This topic has 8 replies, 3 voices, and was last updated 7 years, 12 months ago by Tonya.
-
AuthorPosts
-
April 26, 2016 at 6:24 am #184437leighmMember
On the homepage I'm using the featured page widget, and I've set the content type to "show content limit" and below that I add my more text. In the code I'm using css to make this a button, and I want to right align it in the widget, but I can't using text-align: right because it needs it's on container to do that. It looks like this:
<p>This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like. This … <a href="http://localhost/smcu/the-annul-lunch/" class="more-link">Continue</a></p>
But I need it to look like this:
<p>This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like. This …</p> <p><a href="http://localhost/smcu/the-annul-lunch/" class="more-link">Continue</a></p>
Is there any way to wrap the Continue button in it's own separate paragraph tag? I know there's a function that allows me to overwrite the read more link but I need the text to be different for each featured page widget that I use.
Thanks.
April 27, 2016 at 9:48 am #184522leighmMemberHi,
I'm quite desperate to find a solution for this. The closest I can get is by using this code:
//* Modify the Genesis content limit read more link add_filter( 'get_the_content_more_link', 'sp_read_more_link' ); function sp_read_more_link() { return '... <a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>'; }
And modifying it to add a div around the link like this:
//* Modify the Genesis content limit read more link add_filter( 'get_the_content_more_link', 'sp_read_more_link' ); function sp_read_more_link() { return '<div class=link-wrapper-div><a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a><div>'; }
The problem is that I don't want all these buttons to say: [Continue Reading]. Is there a function that I can use in that place to show the actual text that I entered in the widget for More Text. I know you can enter functions in there as I've tested this:
//* Modify the Genesis content limit read more link add_filter( 'get_the_content_more_link', 'sp_read_more_link' ); function sp_read_more_link() { return '<div><a href="' . get_permalink() . '">' . get_permalink() . '</a></div>'; }
And it returns the permalink as the read more text. It would be great if there was a function that tapped into the actual read more text that I've added in the widget.
Any advise much appreciated.
April 27, 2016 at 10:22 am #184525Victor FontModeratorSee if this helps: http://victorfont.com/how-to-change-the-wordpress-read-more-text/
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?April 27, 2016 at 10:13 pm #184575TonyaMemberHello everyone,
Here is a hands-on lab with free code for you to use. The lab walks you through how Genesis builds the
[Read more...]
HTML markup, how you customize, why it works, and deals with the different child theme setup options, i.e. whether you have a content limit set up or not.Let me know if you have any questions.
Happy coding,
Tonya
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampApril 28, 2016 at 2:19 am #184587leighmMember@Tonya Thanks but the link you sent me to is a paid membership site. Where do I go to see the code snippets?
@Victor Thanks for that code snippet Victor, but I've not been able to adapt it to my project. I'm probably misunderstanding what's going on in this code, but here's my understanding, and how I've tried to adapt it.Your snippet:
// We're adding a filter to the_excerpt part of a post using the vmf_read_more_custom_excerpt function add_filter( 'the_excerpt', 'vmf_read_more_custom_excerpt' ); // The function is taking in 1 agrument, which I'm assuming is the excerpt itself? function vmf_read_more_custom_excerpt( $text ) { // If there's a point in the excerpt that has the ellipses i.e. ... if ( strpos( $text, '[…]') ) { // We create a new bit of text to replace those ellipses? $excerpt = str_replace( '[…]', '<a class="more-link" href="' . get_permalink() . '">[Read More…]</a>', $text ); } else { // not sure what this does? $excerpt = $text; } return $excerpt; }
In my widget I'm using the "Show content limit" option, so I've replaced the_excerpt with the_content_limit, and I've wrapped a div around the Read more link, like this:
add_filter( 'the_content_limit, 'vmf_read_more_custom_excerpt' ); function vmf_read_more_custom_excerpt( $text ) { if ( strpos( $text, '[…]') ) { $excerpt = str_replace( '[…]', '<div><a class="more-link" href="' . get_permalink() . '">[Read More…]</a></div>', $text ); } else { $excerpt = $text; } return $excerpt; }
This code does nothing?
Even if this code did work, wouldn't it just replace what I already have entered into the "More Text" field in the widget, with [Read More...]?
Specifically, I want it to output this html:
<div class="entry-content"><p>This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like. This … <div class="extra-div"><a href="http://localhost/smcu/the-annul-lunch/" class="more-link">Continue</a></div> </p></div>
Rather than this:
<div class="entry-content"><p>This is an example of a WordPress post, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many posts as you like. This … <a href="http://localhost/smcu/the-annul-lunch/" class="more-link">Continue</a></p></div>
Note that the word "Continue" in the anchor text that I've used in the widget, and this should reflect whatever I put into the widget e.g. it could be Continue reading, more, Read more, Buy now, or any text that I put in there.
Again, I'm most likely not understanding the code fully. Any guidance would be appreciated.
Thanks.
April 28, 2016 at 7:06 am #184596TonyaMemberAbove the Introduction video, there is a gray bar that says "Get the Code Here". Click on that bar to open it up. Or you can get it here from GitHub. The Introduction video walks you through an introduction of what the code does. Then the paid episodes go through and thoroughly explain the code, how to build it, what Genesis does, and more. The code and the Introduction video are free and available to you without logging in.
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampApril 28, 2016 at 7:21 am #184598TonyaMemberBTW I should mention that the code I gave to you works for:
- The Posts Page (Blog)
- Archive pages (like Author, Category, etc.)
- Featured Post widget
Happy coding,
Tonya
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer BootcampApril 28, 2016 at 8:19 am #184602leighmMemberWow, thank you so much, Tonya. That worked perfectly. I only wish I could understand the code!
April 28, 2016 at 8:23 am #184603TonyaMemberYou're welcome!
Software & Electrical Engineer and Programming Teacher · I’m on a mission to help developers be more awesome.
Find Me: KnowTheCode.io | @hellofromTonya | Profitable WordPress Developer Bootcamp -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.