Forums

Post Title Link to Source, not Single - & - Comments Link to Single (3 posts)

  1. justinmyoung
    Member
    Posted 2 years ago #

    hi

    I need some help.

    I would like to have the post title link to the source, like a news article. And at the same time offer a comments popup (next to the post title) link to the single.php page which would allow commenting.

    I've tried to accomplish this but have failed.

    This is something this site has achieved http://www.drudge.com/ - but I can't figure it out

    Thanks for any help

  2. Michael Fields
    Member
    Posted 2 years ago #

    The easiest solution would be to use a custom field to store the external link and then modify you theme to recognize the field. You will need to add the following code to index.php and, if present, category.php and archive.php.

    <?php
    	$id = intval( $post->ID );
    	$external_link = get_post_meta( $id, 'external_link', true );
    	$href = ( $external_link ) ? $external_link : get_permalink( $id );
    	print '<h2 id="post-' . $id . '"><a href="' . $href . '" rel="bookmark">' . the_title( '','', false ) . '</a></h2>';
    	comments_popup_link( 'Add a Comment', '1 Comment', '% Comments' );
    ?>
  3. justinmyoung
    Member
    Posted 2 years ago #

    Just wanted to say thanks very much for that bit of code - works great!

Topic Closed

This topic has been closed to new replies.

About this Topic