We will disable purchases soon as we get ready to update our sites (learn more in our forum post). Make sure you complete any transaction or leave it for when our sites are back up. You can monitor the status of our sites here.

151 posts
  • Affiliate Level 4
  • Author Level 6
  • Beta Tester
  • Collector Level 1
+5 more
RoyalTemplates
says

Hi, I have run into a problem which Im not sure is possible with standard wordpress and no extra php. Basically I have a page template for “Hosting Plans” page. This displays a number of custom post types in a table (Plans).

What I would like to be able to do is to add a meta box with a list of “Plans” custom post types for the user to select. Its possible to add the meta box to all pages but I want it to only show if it is a page using the template “Hosting Plans”. Is this even possible?

1 post
  • 5 Years of Membership
  • Canada
  • Collector Level 4
  • Exclusive Author
waywicked
says

Well this is 4 months later and may not help iStudios per se, for anyone else looking check these 2 great links:

http://www.farinspace.com/page-specific-wordpress-meta-box/

and one step back:

http://www.farinspace.com/how-to-create-custom-wordpress-meta-box/
75 posts
  • Featured Author
  • Freebie
  • Trendsetter
  • Exclusive Author
+4 more
geekslabs
says
If your custom page template filename is foobar.php, you can use get_post_meta():
global $post;
if ( 'foobar.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) {
    // The current page has the foobar template assigned
    // do something
}
Personally, I like calling this inside my add_meta_boxes_page callback, and wrapping it around the add_meta_box() call itself.
function wpse82477_add_meta_boxes_page() {
    global $post;
    if ( 'foobar.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) {
        add_meta_box( $args );
    }
}
add_action( 'add_meta_boxes_page', 'wpse82477_add_meta_boxes_page' );

You’ll just need to instruct users to save the page after assigning the template, so that the meta box appears.

by
by
by
by
by
by