make a excerpt on data from a meta box?

You could make use of wp_trim_words: <p><?php echo wp_trim_words( get_post_meta( $post->ID, ‘twpb_news_textnews’, true ), 55, ‘[&hellip;]’ ); ?></p> Or, if you want the filters applicable to the regular excerpts to be used as well, write your own wrapper for it: function wpse115106_news_excerpt( $text=”” ) { $excerpt_length = apply_filters( ‘excerpt_length’, 55 ); $excerpt_more = apply_filters( ‘excerpt_more’, … Read more

I’m confused about URL sanitization in meta boxes

Choice between esc_url and esc_url_raw depends on the use you have to do with the url. If you have to use the url to display inside html use esc_url, E.g.: $my_link = get_post_meta( $post->ID, ‘mod_modbox_link’, true ); echo ‘<a href=”‘ . esc_url($my_link) . ‘”>Open link</a>’ esc_url_raw should be used for any other use, where the … Read more

Plugin “Meta Box”: Implementing meta boxes in custom post type

In this instance you would need to find the hook into the specific metabox and add your custom post type to its pages array, for example: $meta_boxes[‘test_metabox’] = array( ‘id’ => ‘test_metabox’, ‘title’ => ‘Test Metabox’, ‘pages’ => array(‘post’,’page’,’artists’), //list custom post types here! ‘context’ => ‘normal’, ‘priority’ => ‘high’, The Meta Box plugin essentially … Read more

Undefined index error when saving content on metabox

Resolved by following comment on Tutsplus Tutorial (link included): In function save_meta(), replace this line: if (!wp_verify_nonce($_POST[‘custom_meta_box_nonce’], basename(__FILE__))) with this line: if (!isset($_POST[‘custom_meta_box_nonce’]) || !wp_verify_nonce($_POST[‘custom_meta_box_nonce’], basename(__FILE__))) See full comment here.

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