Tag Info

New answers tagged

0

The add_meta_box() functions 4th parameter is where you add your CPT's for the backend. $post_type (string) (required) The type of Write screen on which to show the edit screen section ('post', 'page', 'dashboard', 'link', 'attachment' or 'custom_post_type' where custom_post_type is the custom post type slug) You should be able to add an array for ...


0

This might not be a solution you're looking for, but if you're looking for custom field/box functionality in the back-end of Wordpress, I'd look into Advanced Custom Fields. It's a fantastic plugin that makes modifying the admin side of Wordpress a breeze. You can add multiple Custom Field sets, put the sets inside of Meta Boxes, and specify exactly which ...


0

edit.php is the post/page list, the post creation/editing screen are 2 separate files: post-new.php and post.php. so you can target using "load-$page" hook, e.g.: add_action( 'load-post.php', function() { // add metabox or whatever you want when EDITING post add_action( 'add_meta_boxes', 'myplugin_meta_box_editing' ); } ); add_action( ...


0

Something like this should work: global $current_screen; if ( $current_screen->action == 'add' ) { // you're adding new post } else { // you're editing... } If you want to do this only with one post type, you can check id field like this: if ( $current_screen->action == 'page' ) ... // or post, etc. You need to be careful. You shouldn't ...


1

Short version — there isn't one. WordPress doesn't handle dependencies logic in any form. If library itself doesn't include any mechanism for it (which is exceedingly rare) — there isn't anything you can do. At best you can (and should) check if expected version of dependency is loaded (if it exposes version in some form or at least by location it's loaded ...


0

This includes a custom field named wpsites_textarea. ?> <p><label for="wpsites_textarea" class="screen-reader-text"><b><?php _e( 'Genesis Style Meta Box', 'genesis' ); ?></b></label></p> <p><textarea class="widefat" rows="4" cols="4" name="wpsites_textarea" class="inside"><?php echo esc_textarea( ...


0

You will need to add your post types in an array. So your code should look like this 'pages' => array('post', 'sfwd-courses', 'sfwd-lessons', 'sfwd-topics'), You should also have a look at this tutorial that I find helpful as well


0

You just need to override the function display_tablenav() with a blank function in you parent class. It is explained here.


0

I just ran your initial code myself with wp_debug on and it seems that there is some basic housekeeping needed for this to actually save the data into the custom field. I think your problem so far is that there is no data being saved in, therefore you cannot read anything out. On line 55 and 57 you are trying to prints parts of the array that do not exist, ...


0

This is, what finally fixed it for me: apply_filters('wp_handle_upload', array( 'file' => $file_path, 'url' => $file_url, 'type' => $file_type), 'upload'); Explanation: I'm not quite sure why this fixed the error for me, but I assume that this either has something to do with plugins using the wp_handle_upload hook or that the ...


0

Just use update_post_meta() which will make sure that $meta_key already exists. If it does not, add_post_meta is called instead and its result is returned.


0

If you're updating a value, you want to use update_post_meta. When you set $unique to true in add_post_meta, nothing will happen if the meta key already exists.


3

If you have a look at the template hierarchy, custom post types are usually displayed on archive templates. Normal template hierarchy does not make provision for page.php type templates to be used to display custom post types by default. The problem with archive templates is that they don't automatically get added to the default nav menu, and creating a ...


1

Custom fields or post meta entries can be hidden from the by default in Wordpress available »Cutom Fields«-Metabox by prefixing them with a underscore - _ - as noted here. As addition, if you want hidden fields to be visible during development you can do that easily - take a look at this answer to know how.


1

Install metabox plugin and active: /**** Add this code in your function.php ****/ $meta_boxes[] = array( 'id' => 'post_sidebar', 'title' => 'post Sidebar', 'pages' => array('post'), 'priority' => 'low', 'fields' => array( array( 'name' => 'Post ...


1

I am working on something similar. This is for a podcast upload meta-box. Returns the url to the file. Here is what I have so far: /*******************************************************Podcast Meta-boxes *******************/ //Add Metabox add_action( 'add_meta_boxes', 'add_upload_file_metaboxes' ); function add_upload_file_metaboxes() { ...


5

Meta boxes are saving data at each post ($post_id) $value = get_post_meta($post_id, 'name', true); name = 'dbt_text' or 'dbt_text1' so $value = get_post_meta($post_id, 'dbt_text', true); $value1 = get_post_meta($post_id, 'dbt_text1', true); ~ more info on get_post_meta


1

I created and managed my own custom meta fields for years and I can tell you it was always a headache. I frequently came up against stumbling blocks like yours and ended up banging my fist against the wall. I've also worked on quite a few sites which had been flooded with plugins, sometimes so many that it soured me on plugins altogether and I resolved to ...


0

Your code seems a little superfluous; I'm pretty sure you could compact it to simply: <?php do_action( 'before_sidebar' ); if ( ! $sidebar = get_post_meta( get_the_ID(), '_cmb_test_select', true ) ) $sidebar = 'sidebar-1'; // Default sidebar if meta value does not exist. if ( ! dynamic_sidebar( $sidebar ) ) : ?> <!-- No widgets for ...



Top 50 recent answers are included