Display oembed in repeatable metaboxs using CMB2

So, to answer my own question. In the functions/backend code I made a mistake with this line: ‘id’ => $prefix . ‘media_embed’, In a repeater field it it doesn’t need the prefix and as that is defined in the parent and so it should be: ‘id’ => ‘media_embed’, And for the front end this line: … Read more

get $post (object,parts/values) in meta-box

Do not rely on globals like get_the_ID() or get_post() do. Use the parameters for your callbacks. You get the current post object twice: When you register the metabox, you get the post object as a second parameter. When your output callback is called, you get it as the first parameter. Here is an example showing … Read more

How to remove the “+Add Category” button from the Category metabox?

I installed the ‘User Role Editor’ plugin and removed the ‘manage_categories’ capability for the ‘Editor’ which worked. But I would like to remove it for ALL users including admin, superadmin. If removing the ‘manage_categories’ capability from the editor role provides the functionality you want, then you can remove the ‘manage_categories’ capability from all user roles … Read more

How to add meta boxes to Pages

I’ve got this working finally ($template_file == ‘page-tjenester.php’), so now my meta boxes shows up only when I use this specific page-template! This is the final code if someone is interesting; add_action(‘admin_init’,’my_meta_init’); function my_meta_init() { $post_id = $_GET[‘post’] ? $_GET[‘post’] : $_POST[‘post_ID’] ; $template_file = get_post_meta($post_id,’_wp_page_template’,TRUE); if ($template_file == ‘page-tjenester.php’) { // this will only … Read more

Is it possible to create a post using a metabox?

Update The answer is so simple, I couldn’t see it at first. 🙂 Just remove the action during the first function call. This way, your work within the API, and your function is really called just once. No need for static or even global variables or constants. function my_metabox_save() { remove_action( ‘save_post’, ‘my_metabox_save’ ); // … Read more

Alternative to esc_textarea

esc_textarea shouldn’t strip out newlines — It’s just a thin wrapper around htmlspecialchars: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/formatting.php#L2536 <?php function esc_textarea( $text ) { $safe_text = htmlspecialchars( $text, ENT_QUOTES ); return apply_filters( ‘esc_textarea’, $safe_text, $text ); } That said, there are lots of options. What do you want your users to do have the ability to post? esc_html will … Read more

Woocommerce with metabox plugin

Here’s the metabox code what I’m using which is working fine for me: // Add meta boxes with TinyMCE via wp_editor() function // Define the custom box add_action( ‘add_meta_boxes’, ‘product_details_add’ ); // Do something with the data entered add_action( ‘save_post’, ‘product_details_save’ ); // Adds a box to the main column on the Product post_type edit … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)