Need more detailed “page-interrupt” options [not adding]

Welcome! Support WP-Drudge Features in development Need more detailed “page-interrupt” options [not adding]

This topic contains 12 replies, has 2 voices, and was last updated by  turnout 7 years, 4 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • turnout

    Right now, there is only one option for managing page interrupts (WP Drudge Options > Other > Add interruption page), and you have to either turn them on for the whole site or off for the whole site.

    What I need is to be able to have the homepage be set to have no page interrupts for any links clicked there, while pretty much everywhere else on the site (especially search results and tag/category archive listings) there is a page interrupt.

    This is a critical feature for the website I am working on, so I will be hacking the functionality in via my child theme, but it would be great if this became a feature for the next update. At a minimum, a “Add interruption page on Home,” and “Add interruption page everywhere else” would be nice, but breaking it down into separate options for search results, tag/category listings, etc. would be best. A bonus would be the ability to override these defaults for a particular post from the post creation page, but I realize that might be overkill and a lot harder to code.

    In any case, I would appreciate any advice you may have on how to accomplish this with my child theme. I’m not a PHP expert, but I have the basics down and am comfortable adding functions and stuff. So if you point me in the right direction (which part of which parent theme file to modify, etc.) I can probably figure it out.

    Thanks in advance!

    PROPER Web

    That system ends up being very-much ingrained in how the theme operates, I don’t think it would be a trivial matter to make that change. In fact, I’m not even sure that it would be possible in a child theme, as far as I can conceptualize it. Everything is happening in includes/essentials.php, which can’t be overridden (and probably shouldn’t be since that changes on almost every release).

    The problem is that we’re already doing a lot of work with the links that WordPress is generated. Adding controls that that for the theme at large would be a lot of complexity to manage during testing, etc. Every logical check adds exponentially more options as it’s already doing many different checks as it works.

    Happy to try to help guide through issues as they come up … sorry I wasn’t terribly helpful here.


    Hmmm, ok. Thanks for the quick response!

    How about this: let’s say I set the “Add interruption page” option to “on” so that by default the site always takes a user to the interruption page first. Now, what would I have to change in the drudge_column_posts_widget.php file to make it ignore that setting?

    Is there a $variable I can echo that always has the external link? Or, conversely, a variable that always goes to the interrupt page? Would using get_permalink($pid) do me any good?

    PROPER Web

    In that file, you’re getting all the info on line 104;

    $curr_link = get_drudge_metas(FALSE, TRUE);

    That $curr_link variable holds all the data for that posted link. The headline link HTML is already built, though, in $curr_link[‘link_html’]. The outbound link is always stored in $curr_link[‘link_out’] so you could use that to build a link headline by replacing:

    echo $curr_link[‘link_html’]

    … on line 113 with the HTML that you want to use.

    Hope that helps!


    Ok, that worked great! I replaced line 113 of drudge_column_posts_widget.php with:

    echo '
    <a class="headline-link" href="' . $curr_link['link_out'] . '">' . $curr_link['title'] . '</a>';

    Now the widget (which is only used on the homepage) always uses the direct external link.

    One more question. When I add drudge_column_posts_widget.php to the /inc folder in my child theme, it doesn’t do anything (it only works if I modify the file in the parent theme). Do I have to register the /inc/drudge_column_posts_widget.php in my child theme’s functions.php file or something?

    The development version of the site is here, if you want to see how it turned out:

    PROPER Web

    Site looks great, nice work there!

    The way that child themes work, I don’t think you can override non-core theme files. You can, however, use that file as a template to create your own widget that operates differently.

    I’ll introduce a few more hooks and filters in the next version to address some of these questions.



    I went ahead and added the modified widget to my child theme as a separately named widget, and it works fine.

    I think, though, that if in a future release you were to make your functions pluggable by declaring them conditionally (as described on the WP Codex page for child themes), then I would actually be able to override your widget by declaring mine in the child theme. I may not be understanding that correctly though.

    In any case, thanks for the tips!

    PROPER Web

    A lot them are and, in this case, you could just make another widget. Each release gets a little bit more flexible, though, and I definitely appreciate your feedback on this!


    We took your WP-Drudge theme live over the weekend, and it is working great!

    One issue I’m having is that while my drudge_column_posts_widget2 function, as described above, is using the external link on the actual headlines, the images are still linking to the interrupt page (go to the site to see for yourself). Is there something in the widget function I can tweak? Instead of

    echo $curr_link['image_html']

    Is there something like

    echo $curr_link['image_html_out']

    That will use the external link?

    PROPER Web

    Looks great, nice work there!

    You could replace the link in there with str_replace(). I realize that’s a bit of a hack, though, and I’ll get a fix into the next version to make that easier.


    Ok, I couldn’t figure out how to use str_replace(), but I rebuilt the html for the image for my custom column posts widget by having it echo the following instead of $curr_link['image_html']:

    '<a href="' . $curr_link['link_out'] . '"' . $curr_link['link_insert'] . '>' . '<img src="' . $curr_link['image'] . '" alt="' . str_replace('"', ''', $curr_link['title']) . '" width="' . $width . '">' . '</a>'

    Probably not ideal, but it works.

    One problem I could use some help with, however, is that whenever there is no outbound link, the widget does not link to the post/interrupt page, instead it just links to the homepage. I think this is because instead of $curr_link['link_html'] the widget is echoing:

    '<a class="headline-link" href="' . $curr_link['link_out'] . '">' . $curr_link['title'] . '</a>'

    I guess I need to add an if/else statement in there, but what is the variable for the post page link? Is it just $curr_link['link']? And what condition should I test for with the if/else statement?

    Thanks in advance!

    PROPER Web

    You just need to test if that empty variable is empty and then do what you need to do instead, quickly without testing:

    if (empty($curr_link['link_out'])) {
    $curr_link['link_out'] = get_permalink();


    Perfect, thanks!

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

You must be logged in to reply to this topic.