query with custom field
A quick google search would have directed you to this page: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
A quick google search would have directed you to this page: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
You have to use update_post_meta insted of add_post_meta if(isset($_POST[‘posrav’])) { if($_POST[‘posrav’]!=””) { $posrav=get_post_meta($post->ID,’pcom’,true); $posrav=$_POST[‘posrav’]; update_post_meta($post->ID,’pcom’,$posrav); } }
The following example is adding a meta box to the post edit screen and the wporg_cpt edit screen. function wporg_add_custom_box() { $screens = [‘post’, ‘wporg_cpt’]; foreach ($screens as $screen) { add_meta_box( ‘wporg_box_id’, // Unique ID ‘Custom Meta Box Title’, // Box title ‘wporg_custom_box_html’, // Content callback, must be of type callable $screen // Post type … Read more
According to the documentation for remove_action() the function name and priority must match the usage where the function was hooked. You have made a common sense assumption that a higher priority should be used for the removal but I believe that is the cause of the problem. Docs: https://developer.wordpress.org/reference/functions/remove_action/ To remove a hook, the $function_to_remove … Read more
If you need the ids separated by coma you can get them from the array you have: $listids = implode ( “,” , $postids ); In any case, please provide more info or code about what you need
Well because your code seems like to be bugy/not full – i wrote my code. This will add one meta box with one text field in post (you can change it to be added in your custom post_type)- Post title. Also i had to use QUERY to update/add title, because i can not find any … Read more
If I follow you correctly you want an array of arrays. $get_ref = $_SERVER[‘HTTP_REFERER’]; $ref = get_post_meta($post->ID, ‘page_ref’, true ); $ref[] = array($get_ref); //or $ref[][] = ‘xyz’ …if you prefer update_post_meta($post->ID,’page_ref’, $ref);
do you want this: <?php global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, ‘direccion’, true); if(!empty($meta)) { echo $meta; } ?>
The value of the textarea must be printed between the opening and the closing tag: <form action=”https://wordpress.stackexchange.com/”> <textarea name=”whatever”><?php echo esc_textarea( $description ); ?></textarea> </form> Note the usage of the function esc_textarea() here. It prevents any possible character inside the variable $description from being interpreted as HTML. It’s an important step to avoid possibly XSS … Read more
This is known as array dereferencing and is only available in PHP 5.4+ To support older versions, you need to assign the array, and then access the index: $data = get_post_meta( $product_id, ‘_product_image_gallery’ ); $gallery_pictures_id = $data[0]; Having said that, in your case use the third argument “single”: $gallery_pictures_id = get_post_meta( $product_id, ‘_product_image_gallery’, true );