0
votes

all.

The question- is there any way to load the custom Wordpress templates specified in the page editor 'page attributes' for a page when loaded in a one-page theme?

I'm building custom Wordpress theme in which a client can link to a page that will contain all the info about a certain artist (in this case, different bands) with one back end to manage multiple artists. Thus, if the client wants to send his contact to find info about the band "bar", complete with a bio, music, videos, etc., then he will send a link to 'www.foo.com/bar', which well then load in all of the child pages of the 'bar' page (bio, music, videos, etc...)

I'm using a custom template for each artist page, and have set up a loop to get the child pages to display on the site almost like a category page. (using new WP_Query and 'post_type' : 'page'). The difficulty is getting a custom template to load for each subpage loaded on the one-page site. The reason I need this is because "Music" will need a widget space for a music player, for instance, while "Bios" is WISIWYG.

The template is already locked in, I just need a method for loading each post's template when going through the loop. When viewing the page directly, the page template works, but this template is ignored when the page is loaded in the loop.

Let me know if you need any code. This felt more like a conceptual question that code would complicate.

1

1 Answers

0
votes

not too sure of what you are asking but wp_query is a database query. It loads content into a single template, say for example a custom post template (single-custom_post) if you load child pages into the template you need a method to deal with this. With pages you assign a template at time of saving and the loop pulls database fields.

You could store the template in the post(or page) meta and pull this and load content into it if you want variable content. e.g.

    $videohtml= "<div class="video"> echo "<iframe width="420" height="315" src="<php echo $video; ?>" frameborder="0" allowfullscreen></iframe>"
    update_post_meta( $postid, "videohtml", $videohtml);

    if ($video) {
    $template=get_post_meta($postid, "videohtml", true);
    echo $template;
    }

or more advanced, use get_template_part() (see the codex for this)