Wp doesn’t save meta box data
I had the same problem and solved it by replacing if( !current_user_can( ‘edit_post’ ) ) return; by: if ( !current_user_can(‘edit_post’, $post_id) ) return;
I had the same problem and solved it by replacing if( !current_user_can( ‘edit_post’ ) ) return; by: if ( !current_user_can(‘edit_post’, $post_id) ) return;
Off the top of my head, without actually testing it, this should work. You want to test for is_admin so we don’t go running the code on the front end, then also test for the post type being equal to its slug. Edited this because I made a silly mistake before. Reference this page of … Read more
how do you assign the variable? use something like this? $variable = esc_html( get_post_meta(get_the_ID(), ‘example’, true) ); if yes, try removing esc_html()
The easiest solution is to use jQuery. Add the below code to any JS file that you include in the admin area. As you haven’t given very much information above I don’t know a couple of things, so you’ll need to amend this example slightly – Change your-post-type to the slug of the post type … Read more
Dropping the code quickly into my test set up, I think you are asking why your page metabox is showing your desired post meta inputs. There’s no problem with your add_meta_box() functions. The problem is with your variable $custom_meta_fields. By the time WordPress gets to the end of your file $custom_meta_fields is defined by the … Read more
EDIT You should be using date_create_from_format or its alias DateTime::createFromFormat() to convert on format to another. You can try the following $date = DateTime::createFromFormat(‘m-d-Y’, ’03-09-2015′); echo $date->format(‘d-m-Y’); This will convert 03-09-2015 to 09-03-2015 ORIGINAL ANSWER This is more a PHP question than WordPress question. You can simply use str_replace to change the / in your … Read more
There is a way to do it. Just include that CSS inside header before wp_head() with internal css. And then add the Source using PHP like below <style> .about-img:after { background-image: url(<?php bloginfo(‘template_directory’)?>/img/tola.jpeg); } </style>
So you want to be doing something like this instead… $price = number_format($price_meta, 2); echo $price; The significant part here is the 2, it will add the 2 zeros after the . if you wanted it to not show the zeros you would set this as 0 – No need to be adding in dots … Read more
$urlbox = get_url_desc_box(); if ( !empty( $urlbox[0] ) ) { echo sprintf( ‘<a target=”_blank” href=”https://wordpress.stackexchange.com/questions/66338/%s”>Visit Website »</a>’, $urlbox[0] ); }
I got the answer. Now I have the code function fichasvtmbasicas_meta_box_callback( $post ) { wp_nonce_field( ‘fichasvtmbasicas_meta_box’, ‘fichasvtmbasicas_meta_box_nonce’ ); $fichasvtmbasicas_geracao_field = get_post_meta( $post->ID, ‘_vtmbasica_geracao_value_key’, true ); echo ‘<div class=”unidadeelementotopovtm”><label for=”fichasvtmbasicas_geracao_field” class=”topodaficha_titles”>’; _e( ‘Geração:’, ‘fichasvtmbasicas_textdomain’ ); echo ‘</label> ‘; echo ‘<select id=”fichasvtmbasicas_geracao_field” name=”fichasvtmbasicas_geracao_field”>’; echo ‘<option value=”decima-quinta” ‘ . selected( $fichasvtmbasicas_geracao_field, ‘decima-quinta’ ) . ‘>15ª</option>’; echo ‘<option value=”decima-quarta” … Read more