function pt_add_custom_box()
{
    if (get_post_templates() && function_exists('add_meta_box')) {
        add_meta_box('pt_post_templates', __('Single Post Template', 'pt'), 'pt_inner_custom_box', 'post', 'normal', 'high');
        //add the boxes under the post
    }
}
function acf_location_rules_values_cpt($choices)
{
    $templates = get_post_templates();
    foreach ($templates as $k => $v) {
        $choices[$k] = $v;
    }
    return $choices;
}
Пример #3
0
 function post_templates_dropdown()
 {
     global $post;
     $post_templates = get_post_templates();
     foreach ($post_templates as $template_name => $template_file) {
         //loop through templates, make them options
         if ($template_file == get_post_meta($post->ID, '_wp_post_template', true)) {
             $selected = ' selected="selected"';
         } else {
             $selected = '';
         }
         $opt = '<option value="' . $template_file . '"' . $selected . '>' . $template_name . '</option>';
         echo $opt;
     }
 }
Пример #4
0
 /**
  * Register a metabox for the Post edit screen.
  *
  * @since 0.2.0
  *
  * @uses get_post_template()
  *
  * @see pt_inner_custom_box()
  */
 function pt_add_custom_box()
 {
     if (get_post_templates()) {
         add_meta_box('pt_post_templates', __('Single Post Template', 'genesis'), 'pt_inner_custom_box', 'post', 'normal', 'high');
     }
 }
Пример #5
0
function post_template_dropdown( $default = '' ) {
	$templates = get_post_templates();
	$templates['Default'] = 'default';
	ksort( $templates );
	$templates = array('Default' => $templates['Default']) + $templates;
	foreach (array_keys( $templates ) as $template )
		: if ( $default == $templates[$template] )
			$selected = " selected='selected'";
		else
			$selected = '';
		echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
	endforeach;
}
Пример #6
0
function post_template_meta_box($post)
{
    if ('post' == $post->post_type && 0 != count(get_post_templates())) {
        $template = get_post_meta($post->ID, '_post_template', true);
        ?>
<label class="screen-reader-text" for="post_template"><?php 
        _e('Post Template');
        ?>
</label><select name="post_template" id="post_template">
<option value='default'><?php 
        _e('Default Template');
        ?>
</option>
<?php 
        post_template_dropdown($template);
        ?>
</select>
<?php 
    }
}
Пример #7
-1
/**
 * Load JS for custom sidebar choice dropdown
 *
 * @global $typenow
 * @global $wp_registered_sidebars
 * @global LARGO_DEBUG
 */
function largo_custom_sidebar_js()
{
    global $typenow, $wp_registered_sidebars;
    if ($typenow == 'post') {
        $suffix = LARGO_DEBUG ? '' : '.min';
        wp_enqueue_script('custom-sidebar', get_template_directory_uri() . '/js/custom-sidebar' . $suffix . '.js', array('jquery'));
        $post_templates = get_post_templates();
        $default_sidebar_labels = array();
        foreach ($post_templates as $template) {
            if (in_array($template, array('full-page.php', 'single-one-column.php'))) {
                $default_sidebar_labels[$template] = 'Default (no sidebar)';
            }
            if ($template == 'single-two-column.php') {
                $default_sidebar_labels[$template] = sprintf(__('Default (%s)', 'largo'), $wp_registered_sidebars['sidebar-single']['name']);
            }
        }
        wp_localize_script('custom-sidebar', 'default_sidebar_labels', $default_sidebar_labels);
    }
}