Safely customizing widgets

Community Forums Forums General Discussion Safely customizing widgets

This topic is: resolved

This topic contains 6 replies, has 3 voices, and was last updated by  IoPT 1 year, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30782

    IoPT
    Participant
    Post count: 7

    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!

    #30786

    Susan
    Moderator
    Post count: 9598

    If 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 #.


    Susan @ Graphically Designing I offer theme customizations I tweet!
    I’ve taken up the challenge! – help me answer some of the unanswered posts

    #30787

    cdils
    Participant
    Post count: 423

    I 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 Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #30788

    IoPT
    Participant
    Post count: 7

    Oooh… 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.

    #30824

    IoPT
    Participant
    Post count: 7

    @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.

    #31118

    cdils
    Participant
    Post count: 423

    Yay! 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 Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #31122

    IoPT
    Participant
    Post count: 7

    Oooh… great links.  Thanks!  I will definitely check those out.

     

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.