Support » Fixing WordPress » Using custom field to get a template.

  • Ok so I have a custom field labled artist_name. Thats calls a name. On the posts for that artist I want to use that custom field to call a different template part that I created for each artist. So I have a file called “name”.php in a folder called “artists”. So when a post for that artist comes up I can call the corresponding template piece for the sidebar. I can’t get it to work though because I don’t get how to structure the path. Here’s my snipper of code.

    global $wp_query;
    $postid = $wp_query->post->ID;
    $artist = get_post_meta($postid, 'artist_name', true); ?>
    <?php locate_template( array( 'artists/' . 'echo $artist_name . '.php' ), true ) ?>
    <?php wp_reset_query(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Using custom field to get a template.’ is closed to new replies.