Forums

GD Stars With Custom Fields (1 post)

  1. sirhank
    Member
    Posted 9 months ago #

    HI
    My website is http://www.bestgolfswingtips.co.uk/

    For each post on the Home page I have a button linking to the full post (labelled 'Read The Review')

    I need to put another button next to the 'Read The Review' button that will link to the corresponding website ... I have put the url in a custom field named 'linker'

    The code needs to used in a table environment ie <td> </td>

    I have tried adding this code to the functions.php:

    function url_address($key) {
        global $post;
        $custom_field = get_post_meta($post->ID, $key, true);
    
        if($custom_field) { //if the user set a custom field
            echo '<a href="'.$custom_field.'" />';
        }
        else { //else, return
            return;
        }
    }

    And in the duplicated SRR template I added this code within the <td> </td> tags:

    <?php url_address('linker'); ?>

    I also tried this code:

    get_post_meta($post_id, 'linker' $single);

    Neither of these codes will parse

    Have I got the syntax wrong or am I going about it the wrong way?

    Any help will be very much appreciated

    Thanks

Reply

You must log in to post.

About this Topic