Forums

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

  1. justinmyoung
    Member
    Posted 1 month 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. mfields
    Member
    Posted 1 month 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 1 week ago #

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

Reply

You must log in to post.

About this Topic