• I have an interesting one. The aim is to be able to link posts using custom fields. Here is what I want to do:

    Create 2 categories, Events & Performers.

    Add a new post for each performer. These posts will contain performer bio (post content), image using custom fields, etc and lie in the performer category.

    Add a new post for each event. These posts contain information about the event, plus information about all performers playing at the event.

    I thought this may work by adding a custom field to one of the events post called ‘performer’ and enter the performers name (post title) in there. Do this for all performers at that particular event. Then in the events single.php template I would need to add a loop which first looks at the custom field ‘performer’, gathers all of the names, and matches it to the posts. I then need to display the information from each post gathered onto the events post. So now the events post shows info for the event, from the_content, and say 3 performer posts showing their bio (the_content), image of performer (custom field) etc.

    Here is a snippet of code I found which I thought would be a good start:

    $key="Distillery";
    $distilleryvalue = get_post_meta($post->ID, $key, true);
    $distilleryvalue = $distilleryvalue . " Distillery";
    $distillery_id = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE post_title LIKE '%$distilleryvalue%'");
    $distillery_id = $distillery_id->ID;
    $distillery_meta = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $distillery_id");
    
    echo 'Distillery';
    echo '';
    echo 'Region: ' . $distillery_meta[3] . '';
    echo 'Country: ' . $distillery_meta[7] . '';
    echo 'Official website';
    echo 'Location (at Google maps)';
    echo 'Buy bootles from this distillery (at the Whisky Exchange)';
    echo 'Read more at Wikipedia';
    echo '';

    Any help on this would be really much appreciated!! ??

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Linking posts’ is closed to new replies.