Digg Link Style + Link RSS to source? (6 posts)

  1. ashconnor
    Posted 9 years ago #

    Everyone who has visited Digg knows that when you click the headline of an article that it takes you directly to the source.

    My website I would like to link consumers to products that are on offer/sale etc.

    I am need direction on modifying the Headline of each post so that it links to the product. I would also like direction on modifying the RSS feed, so that too goes straight to the product.

    I think that I would be looking at integrating a new input field and then coding that into the database and php.

    Thanks in advance.


  2. ZMAng
    Posted 9 years ago #

    It's my personal preference not to touch the database unless completely necessary, and I feel it isn't necessary in this case.

    It is possible to do what you want by creating a new custom field for the URL of the product you want to link to, and then, replacing your normal headline with the value of that custom field in your theme's templates.

    See the Codex's documentation on using custom fields for details on pulling the value of your custom field.

    For RSS feed modification, you might want to look at your RSS template files, e.g. wp-rss2.php, and do the same thing.

  3. ashconnor
    Posted 9 years ago #

    OK this is where I stand ATM.

    ID, 'link', $single=true) ?>">Product Link

    I've placed this in the Loop but it isn't aligned where I would like. I think this might be a CSS problem/solution.


    RSS still havent got a clue, I get errors when replacing:

    <link><?php permalink_single_rss() ?></link>

    <link><?php get_post_meta($post->ID, 'link', $single=true)?></link>

    Need help.


  4. ZMAng
    Posted 9 years ago #

    For your RSS2 template, try this to pull the value of your custom field into a variable named $avariablename:
    <?php list ($avariablename) = get_post_custom_values('link'); ?>

    Then, put $avariablename between the link tags, i.e.

  5. theiconoclast31
    Posted 9 years ago #

    If that still doesn't work, although it should, you could always use the following plugin, which lets you call custom fields using a simple template tag:


    Might be overboard, though, if you're using only one custom field.

  6. ashconnor
    Posted 9 years ago #

    ZMAng genius my friend it worked with a little modification.

    I added

    <?php list ($avariablename) = get_post_custom_values('link'); ?>


    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>

    <link><?php print $avariablename ?></link>

    Just need to mod the CSS so that the Product link appears underneath the posts and above the comments and I'm done.


Topic Closed

This topic has been closed to new replies.

About this Topic