• Hello,

    RSS Widget How to open links in new window? Is there a solution for wordpress 6.1.1?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think you need to install the External Links plugin then head over to your Widgets section and add the RSS widget to your site. Select the option to open external links in a new window. Save your changes and you’re done.

    Thread Starter burhi

    (@burhi)

    a solution without plugin would be great

    Moderator bcworkz

    (@bcworkz)

    If you don’t use the suggested plugin, you’d still need to add your own code somewhere, typically as your own custom plugin. So without any plugin isn’t really an option. If you really want to develop your own code, use the suggested plugin’s source code as a guide towards your own efforts.

    Some other possible approaches would be to develop your own RSS block which includes target="_blank" in its anchor links, or have a JS routine that runs after page load and adds the same attribute to all links it finds in any RSS block.

    Thread Starter burhi

    (@burhi)

    i am not an expert ??

    I looked at the class-wp-widget-rss.php file but couldn’t find a section to add “target="_blank

    wp-includes\widgets/ class-wp-widget-rss.php

    • This reply was modified 1 year, 11 months ago by burhi.
    Moderator bcworkz

    (@bcworkz)

    When it comes to blocks I’m no expert either. I think the part you’re looking for is in wp-includes/blocks/rss.php (line 40).

    Do not be tempted to directly edit core files. I suggested looking at them for guidance only. You’d still need to create your own widget. A widget in modern WP is just another block. You’ll want to look at Create a Basic Block to start with.

    Developing blocks can be intimidating to newcomers. AFAIK, the older, “classic” style widgets can still be used. If you’re more familiar with straight PHP than block development, you may find the classic style more accessible. Its development is outlined in the Theme Handbook. Try implementing the sample widget on your site before spending more time with this approach to verify I’m right about classic widgets still working. The drawback with this approach is the existing RSS block/widget code will be less useful as guidance.

    Thanks for this @bcworkz. As much as I wanted to tackle widget building, editing line 40 in the rss.php file worked perfectly. Thanks for the steer. I keep a log of changes I’ve made in case updates reverse them.

    • This reply was modified 1 year, 9 months ago by rschrock.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to open links in new window? RSS Widget’ is closed to new replies.