Community Forums › Forums › Archived Forums › General Discussion › Safely customizing widgets
Tagged: customization, excerpts, genesis, questions, responsive, slider, support, widgets
- This topic has 6 replies, 3 voices, and was last updated 11 years, 8 months ago by IoPT.
-
AuthorPosts
-
March 23, 2013 at 3:34 pm #30782IoPTMember
Now that I have my Responsive Slider printing excerpts I have two types of panel to put there:
Full-length posts with [Read more...] click-through.
News items where the entire post fits in the slider.For the second type of post, it doesn't make sense to allow the reader to click through to what is essentially a dead-end path. There's nothing more to read on the post than was in the slider. So to fix that, I've modified the Responsive Slider code. The routine that prints the title now includes the link only if an excerpt exists. This forces me to *always* write an excerpt, but it was better than coding up a new custom setting for the widget. (At least I believe it was but that's part of my question. See below.) I considered tapping into the_title() but didn't see a way to do that within the slider widget without affecting the the_title globally.
<?php
if ( $show_title == 1 ) {
if ( ($show_type != 'full') && (empty($post->post_excerpt) ) ) { ?>
<h2><?php the_title(); ?></h2>
<?php
} else {
?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php
}
}
?>
Problem is now I'm responsible to go and restore the customizations every time the widget is updated and auto-update breaks the site. So what I'm wondering is:
A) is it possible to achieve the same behavior using features of the slider I've overlooked?
B) if not then could I have changed this somewhere that won't be overwritten?Thanks!
March 23, 2013 at 3:46 pm #30786SusanModeratorIf I'm understanding your questions correctly, you don't want certain posts which appear in your slider to be clickable, but want others to be?
If you don't want the the reader to click through to a dead-end post, go into the post and edit it. Scroll down to Custom Redirect URI [?], and either type in the URL of your homepage or #.
March 23, 2013 at 4:07 pm #30787cdilsParticipantI wouldn't recommend changing the plugin code for the reasons you mentioned.
I'm thinking you could use a filter to achieve your results, but I'm not 100% what it is... Here's the Genesis Filter Reference: http://my.studiopress.com/docs/filter-reference/ in case that helps. 🙂
Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂
I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.
March 23, 2013 at 4:08 pm #30788IoPTMemberOooh... Cool! Elegant! Wish I'd thought of that. I'll try it out after dinner. The wife is complaining about being a "WordPress Widow" these last couple of days.
March 23, 2013 at 10:12 pm #30824IoPTMember@Susan, it was a good idea but didn't pan out. The redirect URI always ended up on the post page, not the current page where the excerpt was printed.
@cdils, I got it to work with a filter registered in the functions.php file as follows:
function IoPT_excerpt_read_more_link($output) {
global $post;
if (empty($post->post_content)) {
return $output;
}else {
return $output . '<a href="'. get_permalink($post->ID) . '">Read More...</a>';
}
}
add_filter('the_excerpt', 'IoPT_excerpt_read_more_link');
I disabled linking the image and title insertion. Then for any post that I want to feature in the slider, I am required to make an excerpt and to manually include the title wrapped in <h2> tags. If I don't want to link to the page, I simply leave the page content empty and write only the excerpt. If I put any content at all in the page, the more link is generated. Even better, my preference was to link to the top of the page rather than to the more anchor and this accomplished that goal. Another added bonus is that I can now also include an image at the top of the post since the content is never used in the slider. Sweet!
Thanks, everyone for all the help! And I do mean everyone. Even though the one idea didn't work out, I know a lot more about all this tonight than I did this morning.
March 25, 2013 at 8:58 am #31118cdilsParticipantYay! Glad you got a solution. It's fun to figure things out. 🙂
You might have fun perusing code snippets from other Genesis people over on Github. Start with Brian Gardner (https://github.com/bgardner) and then check his follower list to discover other people & snippets.
Cheers,
Carrie
Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂
I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.
March 25, 2013 at 9:25 am #31122IoPTMemberOooh... great links. Thanks! I will definitely check those out.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.