I think it’s generally better to include the CMB2 plugin. As far as your question, there are a lot of ways to go about this, but I think your way is a solid one. I would make a couple changes. I’d update your option values to be the name of your template-parts:
'options' => array(
'single-video' => 'Single Video',
),
Then I would add a helper function to your theme’s functions.php:
function idver_get_post_template_part( $post_id ) {
$template = get_post_meta( $post_id, 'temp_ver', 1 );
if ( ! $template ) {
$template="default"; // Whatever your fallback template part is
}
get_template_part( $template );
}
(obviously, update ‘default’ to whatever your default/fallback template part should be. If NO default, that helper function should be updated a bit)
Then in your single.php, just call:
idver_get_post_template_part( get_the_ID() );
Related Posts:
- Add custom meta box on Post page
- Let author add field to metabox by pressing a button
- WordPress 3.1.2 Bug: add_theme_support() and video post format registering twice
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- Make Custom Metaboxes Collapse by Default
- How to add a new product type on woocommerce product types? [closed]
- Check for and enforce unique value in user-entered custom meta field in WP Admin
- Adding another state (spam, reject, approve) to wordpress comments?
- echo value from ‘select’ field type into page template using cmb2?
- How to remove Profile Picture section or the message “You can change your profile picture on Gravatar.”
- Post format selector in Thematic child theme post class
- Add field to posts (checkbox) that only one post can have
- generate unique number when registering a user
- How to rotate the header image per day?
- Problem in custom meta boxes
- How to get value from custom backend menu
- How to show only Standard Format post in my custom taxonomy page -wordpress 3.8.1
- WooCommerce Checkout page customization [closed]
- Multiplile values checkbox or select in custom meta box
- Allow Users to Set Password During Registration
- Custom protected password page with ACF
- Add URL field to the link post format
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Add ‘Right Now’ widget to custom dashboard
- Passing page url into a custom field via the Press-This bookmarklet
- How to extend nav-menu-item-control data in Appearance > Customize?
- Custom column sorting in WordPress admin post table
- How to get multiple Action Hooks in an Array
- woocommerce Add custom field set like billing fields
- Security checking in meta_box save is reluctant?
- Woocommerce with metabox plugin
- Dynamically add / duplicate custom meta in custom post types
- Creating Search Engine Friendly URL’s with Word Press
- Hide custom field if empty
- FacetWP group listings by custom field [closed]
- Custom Field Template seriously messed up in WP 3.1.1
- Make wordpress generate a custom XML file(not a sitemap) that is updated only when new content is posted?
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- list/consult Taxonomy only for the respective author/creator in dashbboard
- Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date
- Custom Taxonomy to dropdown box on adminside wordpress
- The Best Way to always load the newest version of 3rd party code
- Better Method for Multiple Meta Boxes
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- Why do posts disappear from admin after upgrading from WP 2.7.1 to 3.0.1?
- How to change popular term checklist title when edit post?
- Add a date updated/date modified option using custom fields
- How to add textarea field to taxonomy (tag)?
- How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
- Woocomerce custom billing address fields display in order details [closed]
- custom meta box for page default template
- Cannot save CPT meta box
- How to get Related Custom Posts?
- WordPress metaboxes – textfield suggestion automatically populated
- I need a “Choose from existing content” popin
- Qtranslate + Woocommerce (multiple tinymce) [closed]
- Changing settings of WooCommerce
- Redirect to another page using contact form 7? [closed]
- What requirements for ACF custom fields key and name properties?
- How to insert a writing panel between the title and the page content?
- Toggle custom fields?
- Data won’t save if metabox within conditional in admin. What am I missing?
- Woocommerce – Print Product’s Custom Field In Email
- How can I hide custom field from users used for caching response from external api?
- Let’s Create Custom Field Template Documentation
- How to print Array values of custom Fields Meta?
- Get users based on month ACF datepicker field
- What is the best way to modify Admin Panel on WordPress?
- how to make a custom field readonly or disabled by user role?
- theme customizer – can a single option pass multiple values?
- MetaBox not saving after empty
- Make tag archive display post are ordered by post format
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- How to auto add nofollow to links in custom field?
- Meta Tags by Meta Box
- How Can I limit the visible part of the short-description on the Category page?
- Custom meta boxes not saving
- Translating (WooCommerce) placeholder text
- WooCommer Product Category Loop – How to change the display order of the rating and price?
- Changing the body of mail sent to new user registration
- Does WordPress support template resources/custom fields
- When post is updated, custom metadata in text area field is overwritten
- Get a different size of Image thumbnail while working with custom metabox
- How to make my wordpress site responds for 2 domains
- Where can I find the code for the menu page meta boxes?
- How can i do custom author list?
- Need Advice to Working with Custom Post Meta
- Extending a CPT by Created by another plugin
- Custom Slider Per Page created
- Need help saving input fields for Security Deposit plugin in WC Vendors page
- Admin new order email customization
- How I can change PayPal IPN ‘custom’ field in woocommerce?
- Consolidate ‘add-to-cart’ buttons into one ‘add-all-to-cart’ button
- How to change data format in custom meta box field [closed]
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Add custom information in editor summary
- Customise “Add a New Post” page
- Need to add custom cart item data