WordPress.org

Ready to get started?Download WordPress

Forums

External Links (4 posts)

  1. dashton
    Member
    Posted 4 years ago #

    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?

  2. dashton
    Member
    Posted 4 years ago #

    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; ?>
  3. kato
    Member
    Posted 4 years ago #

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

  4. kato
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.