• I have a news aggregator type site that also has my own posts. I want my post titles to link to OR redirect directly to external articles and I want the post titles in this format:

    ARTICLE TITLE (SOURCE)
    Article title being the newspaper/blog/magazine article and source being the name of the newspaper/blog/magazine… When you click on this title, I want the reader to be directed to the article/post on the original website… Random example:

    <a >WordPress Update 6.2.1 Causing Sites To Break (Search Engine Journal)</a>

    QUESTION: Is there a way (a code or something in the post title?) for me to do this using the basic tools, blocks, codes etc WP provides without a plugin or specialized theme that will need constant updates???

    MY PROBLEM: I had an old news aggregator theme that did this BUT the recent update to PHP 8.0 and WordPress 6.2.2 caused it to break my site as its original developer sold it to someone who has stopped working in it.

    Ideally, DON’T want to use another such news aggregator theme (if one even existed…) or a plugin to do this and go through this trouble again e.g. have updates to the theme or plugin stop and then have it unable to work after so many PHP-WP updates…

    It seems WordPress can now do ALOT more w/o the need for coding or specialized themes/plugins and all the trouble that comes with them e.g. I have already used the WP RSS block to eliminate a faulty out of date RSS feed plugin that stopped providing a post tag feed at the end of my static pages AND I was able to create a multi-column static front page of links to numerous news resources + an RSS feed of my posts just like I previously had with my aggregator theme…

    I just can’t figure out if there is an easy way to have post titles redirect to external sites…

    At the moment, I am just using the FREE GeneratePress theme BUT can change it back to one of the free WP themes IF need be as I don’t want to be locked into a premium theme or plugin + there tends to be more documentation with standard WP themes for coding…

    • This topic was modified 1 year, 5 months ago by bcworkz. Reason: spammy link made into code
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    The template code that outputs the title would need to be altered to make it into the desired link. How to do so depends on where PHP can find the outside link that should be used. Finding it within post content is far from ideal, but feasible if necessary. It’d be better if the link was in post meta or somewhere within the DB that’s readily accessible and somehow related to the post.

    Thread Starter WPUser916

    (@wpuser916)

    Sounds complicated though… I see an article titled “How to Link WordPress Post Title to an External URL?” suggesting a plugin called “Page Links to” plugin BUT it has not been updated in a year BUT it has 200,000+ Active Installations… Are you aware of any other plugins that I can check to see if they are updated?

    The article also gives a bunch of code for the “theme’s functions.php file or a site-specific plugin” to create a “Custom fields” meta box or something which sort of makes sense. I guess I can download a plugin to input some of the code into to avoid the risk of messing with the PHP files themselves (or child theme?)… I might change themes back to an original WP one (given they have alot of documentation, flexibility + regular updates) as I can’t seem to get rid of featured images and another minor annoyance w/o going premium – the free theme version may also block plugins like “Page Links to” from working….

    Moderator bcworkz

    (@bcworkz)

    Plugins that have not been updated for a long time can still work correctly, but you’d be doing so at your own risk. Such a plugin is unlikely to still be supported by its author. There’s little harm in trying something to see if it works. But even if it works now, it might not work in the future after you’ve become somewhat dependent upon it. Use of unmaintained plugins is best left for those with the skills to do their own patching.

    I’d be surprised if a theme actively blocks a plugin, however it could possibly manage titles in a way that’s incompatible with the plugin. The plugin likely uses “the_title” filter to alter title output. But this requires the theme to use the_title(). Many do, but it’s not mandatory. It’s not uncommon to find themes that do not use it.

    I encourage you to develop your own solution. In the end, it’s probably not as complicated as it now seems. As long as you have a backup you can revert to if you run into trouble, there’s little harm in trying, other than losing time spent.

    You can save the destination link in a custom field using the default custom field panel. It might be hidden in your instance of the editor. Use the 3 dot icon > Preferences > Panels dialog box to reveal any hidden panels.

    Let’s say you save the URL under key name “post-dest”. The template code might look something like this:
    <a href="<?php echo get_post_meta( get_the_ID(), 'post-dest', true ); ?>"><?php the_title( '<h1 class="entry-title">', '</h1>'); ?></a>
    This would replace whatever your theme template currently does to output the title.

    Your suspicion is correct, you should create a child theme to contain any template files you’ve customized. While making a child theme is relatively simple, it can still be daunting and confusing to the uninitiated. Follow the linked instructions carefully and all will be fine. In particular carefully read the section about enqueuing stylesheets. The correct code to use depends on what your parent theme currently does to load its own style.css file. IMO this is actually more involved than making the title link to the source article. It’s still not all that complicated.

    You can temporarily test out my suggested title code on an existing theme template without a child theme. Just be sure to keep an unaltered backup copy. Typically the single.php template would be where such code can reside, or possibly a template part that’s referenced from single.php. If you like the results of this test, then you’ll know it’s worth the effort to make a child theme to contain your modified template file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘News Aggregator: How to have post titles redirect to other sites?’ is closed to new replies.