• I have a “Headline” board setup for my blog using a query to gather posts from a particular category. The headline board is at the top of the site, and I want to share links to other blogs when I find a interesting article from them.

    Is there a way to have the title link to an external site? So instead of going to my single.php it goes to the post on another website. Is there any way to use custom fields to determine what link is the permalink?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dashton

    (@dashton)

    Anyone? I just want to be able to pull articles from other blogs and link directly to them. I’ve thought about using FeedWordpress and setting the links to go to the original website but I do not want a flow of posts when I want to be able to pick and choose from time to time, and from a variety of websites.

    Here is what I have setup for my headline right now, it pulls posts from a category. I want to be able to publish a post, but link the title of the post to a different site.

    <?php
    $featuredPosts = new WP_Query();
    $featuredPosts->query('showposts=12&cat=7');
    while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
    <div class="headlines"><a href="<?php the_permalink() ?>"><?php if (strlen($post->post_title) > 50) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 50) . '...'; } else {
    the_title();
    } ?></a>
    <?php endwhile; ?>

    kato

    (@kato)

    You might try using Magic Fields.
    https://magicfields.org/getting-started/
    That should make it a LOT easier for you.

    kato

    (@kato)

    OK, I gave it some thought. You can accomplish this without all the overhead of an extra plug-in like Magic Fields.

    Find in your template (/wp-content/themes/index.php) the place where the Permalink is being called: href="<?php the_permalink() ?>"

    Keep the href=""
    and replace the <?php the_permalink() ?>
    with

    <?php $Link = get_post_meta($post->ID, externalLink, true); if (!empty($Link)) { echo $Link; } else { echo get_permalink($post->ID); } ?>

    Then in your individual posts, add a custom field with the name externalLink

    and for the value of that externalLink, add your external URL.

    Let me know if that works for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘External Links’ is closed to new replies.