开发者

Best way to layer Custom Posts regarding structure and data

I would like to know the best method for layering posts in wordpress 3.0 when you need to swap back and forth between structure and data. For example, custom post type 1 has 6 custom fields, each field contains a value for the tab shortcode; i.e. [tab:data] [tab:credits] [tab:where to 开发者_如何转开发buy] etc - this type is standard every time the page is called and always the same post; then it needs to switch to another custom post type and select the data post it's going to use based on what tag page is being called. Then it needs to pump a custom field from data post into the same display space as the base structure post, and then hop back and forth between structure and data, and THEN run a loop. Thanks in advance.


I would just query for the two special posts before you do the loop, with get_posts (which will not mess up the regular query). Then you can display them however you want, with their information mixed together, and then do the loop.

In this example, $fixed_post is a fixed post with slug "fixed_post_slug" of the custom post type "fixed_posts". $tag_post is a post where the name equals the current tag (if we are showing a tag page), and of custom post type "tag_posts".

$fixed_post = get_posts(array('name' => 'fixed_post_slug', 'type' => 'fixed_posts'));
if ($fixed_post) {
   $fixed_post = $fixed_post[0]
}
$tag_post = get_posts(array('name' => get_query_var('tag'), 'type' => 'tag_posts'));
if ($tag_post) {
   $tag_post = $tag_post[0];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜