Tag Info

New answers tagged

0

I have solved this problem after many researches, just comment two lines in meta_box.php file at end. $sanitizer = isset( $field['sanitizer'] ) ? $field['sanitizer'] : 'sanitize_text_field'; to //$sanitizer = isset( $field['sanitizer'] ) ? $field['sanitizer'] : 'sanitize_text_field'; at line 692 and $new = meta_box_sanitize( $new, $sanitizer ); to ...


1

From what I can tell, this stems from your use of get_post_field(), which is reserved for fields found in the posts table of the database (ie: built-in to WordPress, rather than custom fields). For custom fields you should use get_post_meta().


0

With respect to @cybmeta's contribution, I think that the Types plugin may be throwing us a curveball. He is correct in that you cannot (at least in this context) add a filter at the point of save_post without creating an infinite loop. As I was trying to access the value of a meta field, his suggestion for updated_post_meta may be appropriate, but didn't ...


0

You can not put condition in callback function as it will display the meta box without the HTML. Better you can wrap add_meta_box() in if condition. If you are on post edit screen you can get the post id in this way. $post_id = false; if (!empty($_POST['post_ID'])) { $post_id = $_POST['post_ID']; } else if (!empty($_GET['post'])) { $post_id = ...


1

You hook the tr_change_show_title to a filter inside the function itself, that can make a infinite loop. All the stuff removing/adding actions and filters inside the functions should be deleted; instead check if the post data should be updated or not. In your case you should check if the title has the value you desire or not, if not run wp_update_post with ...


0

I also run into this situation. Here what i did: $args = array( 'post_type' => 'my-post-type', 'meta_query' => array( array( 'key' => 'latitude', 'value' => sprintf(':"%s";', $value), 'compare' => 'LIKE' ) ) ); Hope this help


0

This is what worked for me in the end. I used this to add a metabox: <?php add_action( 'add_meta_boxes', 'so_custom_meta_box' ); function so_custom_meta_box($post){ add_meta_box('so_meta_box', 'Additional', 'custom_element_grid_class_meta_box', 'event', 'normal' , 'high'); } add_action('save_post', 'so_save_metabox'); function so_save_metabox(){ ...


1

I packed everything together. Consider using wp_enqueue_script() to use the script. With this code, you will save all URLs as an array. See how I use get_post_meta() to retrieve the saved URLs. function save_custom_metabox($post_id){ if(!isset($_POST['source_post_metabox_nonce'])) : return; endif; if(!wp_verify_nonce( ...


0

First, throw away your custom walker. Post URLs are called permalinks, and as with most things in WordPress, you can filter them! There is a filter called post_link that lets you modify the URL of the post before it's returned in get_permalink(). We can use this, along with the posts slug, and the home_url function to get something similar to this: ...


0

Be more efficient to code it this way in this case rather than use an array_push add_filter('postbox_classes_post_postexcerpt','add_excerpt_metabox_custom_class'); function add_excerpt_metabox_custom_class( $classes ) { $classes[] = 'custom-class'; return $classes; }


0

I had the same problem while I was using CMB plugin, I solved adding a custom function to functions.php to get the image ID using the image url: functions.php function cmb_get_image_id($image_src) { global $wpdb; $image = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_src )); return $image[0]; ...


0

Verify that the "GD" php library is enabled. You can do so by adding phpinfo(); to one of your php templates and then search the result for GD or GD Support. The GD library is used for image manipulation and resizing is one of those functions. To enable GD on windows you can edit the php.ini file in your php installation and uncomment the php_gd2.dll ...


0

try getting the values with the POST, then you can try this $wpdb->update('meeting_options', array(fieldsGoHere);


1

You can also do by this <?php the_post(); if ( is_home() ) { ?> <meta name="description" content="YOUR DESCRIPTION" /> <?php } elseif (is_single()) { ?> <meta name="description" content="<?php the_excerpt(); ?>" /> <?php } ?> this will set different description for home and other.


0

I recommend not reinventing the wheel and looking at Reusable-Custom-WordPress-Meta-Boxes Even though this code is no longer supported it's concise enough to be easily manageable. I use it and it works well. All you need to do is add the meta_box.php file to your functions.php and from then on use the predefined components: ...


0

I have no time to write at your code, but with your help works for me function wms_add_headerimage_cb( $post ){ //campuri $values = get_post_custom( $post->ID ); $headerpageimage = isset( $values['headerpageimage'][0] ) ? esc_attr( $values['headerpageimage'][0] ) : ''; $img_src = wp_get_attachment_image_src( $headerpageimage, ...


0

I was racking my brains out with this too and was finally able to find a solution that works. This should work for you, I've tested quickly. I'll present it in 3 parts: PART 1: ADD THE CUSTOM META BOX add_action( 'add_meta_boxes', 'add_custom_box' ); function add_custom_box( $post ) { add_meta_box( 'Meta Box', // ID, ...


0

So I was really overthinking this problem. Hopefully my answer can help someone in the future. Basically all I needed to do was save the array from wordpress and check to see if the user_ID (Associative Array Key) was in the Array, if it was and the user needed to change the value I needed to search throughout the array replace the value and update that ...



Top 50 recent answers are included