How do I add these to a Post?
]]>Thank you for your help!
<?php
add_action( 'add_meta_boxes', 'musicreleases_linktype_meta_box_add' );
function musicreleases_linktype_meta_box_add()
{
add_meta_box( 'musicreleases_linktype_meta_id', 'Link Type (Optional)', 'musicreleases_linktype_meta_box_cb', 'eprmusicrelease', 'normal', 'low' );
}
function musicreleases_linktype_meta_box_cb( $post )
{
$values = get_post_custom( $post->ID );
$radio = isset( $values['meta_box_musicreleases_linktype'] ) ? esc_attr( $values['meta_box_musicreleases_linktype'][0] ) : '';
wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
?>
<p>
<input type="radio" name="linktype" value="free" <?php echo ($radio); ?>/> Free<br />
<input type="radio" name="linktype" value="itunes" <?php echo ($radio); ?>/> iTunes<br />
<input type="radio" name="linktype" value="none" <?php echo ($radio); ?>/> None<br />
</p>
<?php
}
add_action( 'save_post', 'musicreleases_linktype_meta_box_save' );
function musicreleases_linktype_meta_box_save( $post_id )
{
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
if( !current_user_can( 'edit_post' ) ) return;
$allowed = array(
'a' => array(
'href' => array()
)
);
if( isset( $_POST['meta_box_musicreleases_linktype'] ) )
update_post_meta( $post_id, 'meta_box_musicreleases_linktype', wp_kses( $_POST['meta_box_musicreleases_linktype'], $allowed ) );
}
?>
]]>function new_meta_boxes() {
global $post, $new_meta_boxes;
$tab_index_count = 30;
foreach($new_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
$textarea_name = $meta_box['name'];
$textarea_id = str_replace('_', '' , $textarea_name);
if($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( basename(__FILE__) ).'" />';
echo '<h3>'. $meta_box['title'] .' - '. $meta_box['description'] .'</h3>';
/* var_dump($new_meta_boxes); */
echo '<div class="">';
echo ' <script type="text/javascript">edToolbar("' . $textarea_id . '")</script>';
echo '<textarea rows="6" class="form-input-tip" cols="80" name="'.$meta_box['name'].'_value" tabindex="' . $tab_index_count . '" id="' . $textarea_id . '" style="width: 97%">';
echo wpautop($meta_box_value);
echo '</textarea> <script type="text/javascript">';
echo 'edCanvas = document.getElementById("' . $textarea_id . '");</script>';
/* echo 'console.log(edToolbar())</script>'; */
echo '</div><hr width="60%"';
$tab_index_count++;
}
}
Thanks
]]>For one of my clients, I use the excellent custom write panels code provided by wefunction.
It works fine except when I move the database from the current domain to a new one:
When I change the postmeta values in the database in order to have the customfields matching the new domain name, the database is updated fine but the custom write panels return nothing as if they were blank. So value from these custom write panels are not displayed on the website…
I use this mySQL query to update postmeta table:
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, ‘https://www.oldsiteurl.com’,’https://www.newsiteurl.com’);
The strange fact is if I update the custom write panels through the post edit panel, it works. But I’d like not to update manually every post and page of the website!
Any help would be greatly appreciated!
]]>I’m trying to split the Categories meta box on the write post page into two meta boxes (showing each all sub-categories of a specific category).
I tryed to add new meta boxes:
add_meta_box( 'my_sectionid', __( 'Categories', 'my_textdomain' ), 'cat_box1_inner_custom_box', 'post', 'side' );
and:
function cat_box1_inner_custom_box() {
global $post, $categories;
// Use nonce for verification
echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' .
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
// The actual fields for data entry
$cats = wp_get_post_categories($post->ID);
?>
<ul id="category-tabs">
<li class="tabs"><a href="#categories-events" tabindex="3"><?php _e( 'Event Categories' ); ?></a></li>
<li class="hide-if-no-js"><a href="#categories-loc" tabindex="3"><?php _e( 'Locations' ); ?></a></li>
</ul>
<div id="categories-loc" class="tabs-panel" style="display: none;">
<ul id="categorychecklist-loc" class="categorychecklist form-no-clear" >
<?php wp_category_checklist($post->ID, 39, $cats); ?>
</ul>
</div>
<div id="categories-events" class="tabs-panel">
<ul id="categorychecklist-events" class="list:category categorychecklist form-no-clear">
<?php
$cats = wp_get_post_categories($post->ID);
wp_category_checklist($post->ID, 3, $cats); ?>
</ul>
</div>
<?php
} ?>
How do I save the selected categories? Someone able to help?
Thank you!
(I’m aware that this code / CSS IDs gets “in the way” of the normal category meta box.)
]]>I was wondering if it possible to hide the link that is created on the left in the Admin Panel. Every time you create a write panel it makes a new “button” for that write Panel. It is put in the same area as the Posts, Media, Links, Pages and Comments buttons are held.
As far as I have been able to find, Flutter’s settings allows you to “hide” the default Posts and Pages buttons in the Admin panel, but it won’t let you hide the new write panel buttons the plug-in creates. I’d like to create these new Write Panels for specific pages, but I don’t want the buttons to show up. I want the client to only use the Pages button.
The problem is if I create tons of custom Write Panels for different pages, then there will be tons of extra buttons on the Admin Panel that I don’t need. Anyone know if you can stop these from being added to the Admin Panel?
]]>Alberto
]]>