Articles of custom field

Adding a Nav menu to post admin

i want insert a dropdown menu with list of menus, that i’ve created in nav-menu.php, to post-admin… For example, when i’m creating a post, i want insert a menu “Paul” in a post (only a post that i want) selecting a menu at right sidebar of Admin-Post. I’ve copied the rows: add_action( ‘init’, ‘register_my_menus’ ); […]

Determine when a custom field was last updated?

Would anyone know of a way to determine when a custom field for a post was last updated? I’m trying to write something that says “If CUSTOMFIELD was updated in the last 24 hours don’t do anything, else update it” but don’t see any time stamps in the database for this. Any clever ideas floating […]

Security checking in meta_box save is reluctant?

For example, in this tutorial, the code suggested when saving meta box data is /* Verify the nonce before proceeding. */ if ( !isset( $_POST[‘smashing_post_class_nonce’] ) || !wp_verify_nonce( $_POST[‘smashing_post_class_nonce’], basename( __FILE__ ) ) ) return $post_id; /* Get the post type object. */ $post_type = get_post_type_object( $post->post_type ); /* Check if the current user has […]

How to get custom field image url of specific size

I have a “cmb2” custom field with type->file. and i use it to upload images. If i use: echo get_post_meta( $post->ID, ‘_pf_photo1’, ‘medium’ ); i get the url of the full image (not the medium one). How can i get the url of the ‘medium’ / ‘thumbnail’ and so on…

Separate table or usermeta

We are creating custom fields for users like annual income, gender, city, country, etc. There are about 10 odd new fields. We will be importing approx. 30,000 records for each user in a month through a CSV import function. There will be new as well as update to old records. The process will continue for […]

custom field to always to .get_the_title()?

Is there a way to have always the the_title() tag also includes a custom field called subtitle? I want to have a title like this: “subtitle-custom-field: Post Title“. For example, “Cool: The new TV show from Werner Herzog.” In this case, cool would be the custom field value, and the new TV… would be the_title(). […]

How to get a meta value from all post

I searched for a while but I didn’t find any solution. I used the functions listed here. It outputs something like this: Array ( [0] => 15 [1] => 30 [2] => 50 ) But I want something like this: Array ( [post_id_1] => 15 [post_id_2] => 30 [post_id_3] => 50 ) And this is […]

Per site configuration

I’m building a custom theme that I will reuse on more than one site and would like to be able to configure some things from the admin. For example setting the Twitter and Facebook pages links without hardcoding them in the template. What’s the best way to do this? Should I put them in wp-config […]

Force hide custom field metaboxes

How can I completely remove the custom fields and the collapse button in the Edit Post/Edit Page custom screen, but without removing the capability to add custom fields with a PHP function?

ORDER BY custom field value

Based on example here I’d like to modify the query $q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => ‘Wisconsin’, ), ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => ‘city_clause’) ); to be able to get all posts where […]