Append “…” After the Text
Lab: Customizing the “Read More” Link in Beans
Video Runtime: 06:06
What if you want to remove the icon and replace it with a "..."
? How would you do that? Think about it. Think about the code from the last episode. You have the default text coming into your callback. That means you can concatenate that string and append the dots after the incoming text.
add_filter( 'beans_post_more_link_text_output', 'beans_child_change_read_more_text' ); /** * Change the "read more" text to "Learn more". * * @since 1.0.0 * * @param string $text "Read more" text * * @return string */ function beans_child_change_read_more_text($text) { return "{$text}..."; // return 'Learn more...'; }
-
Need to brush up on your PHP string concatenation?
Pro Tip
When embedding a variable into a string, make sure you wrap it in curly braces. Why? (1) It clearly defines your intent. (2) It promotes consistency when working with simple to complex string expression. Learn more here.
When was the last time you got out of your chair and stretched? Just saying…
Episodes
Total Lab Runtime: 02:21:26
- 1 Lab Introductionfree 17:36
- 2 Let's Look at the HTML Markupfree 09:16
- 3 Find Where Beans Renders the "Read More"pro 15:37
- 4 Remove the >> Iconfree 09:46
- 5 Change the "Continue reading" Textfree 08:03
- 6 Append "..." After the Textfree 06:06
- 7 Dive into Bean's beans_output()pro 15:46
- 8 Dive into Beans' beans_open_markup()pro 15:50
- 9 Dive into Beans' beans_close_markup()pro 03:04
- 10 Adding HTML Attributes using beans_add_attributes()pro 09:10
- 11 Style It to Look Like a Buttonfree 04:04
- 12 Add UIKit Button Attributespro 08:16
- 13 No More Inline. Put On A New Linepro 01:48
- 14 Wrap It in a Paragraphpro 05:11
- 15 Change the UIKit Iconpro 06:32
- 16 Wrap it Upfree 05:21