How to Find List of Available Custom Fields for Theme?
How to Find List of Available Custom Fields for Theme?
How to Find List of Available Custom Fields for Theme?
I’m not sure you can do this with MySQL alone, since you’d need to save values and reuse them. Here’s a PHP version. <?php global $wpdb; // select all the old postmeta $oldData = $wpdb->get_results(“SELECT * FROM wp_postmeta WHERE meta_key = ‘tnid_01old'”); // make sure we have results if($oldData) { // loop through each result … Read more
You’ll need to change your search form, PHP uses fieldname[] notation to accept multiple values for a parameter name. <input type=”checkbox” name=”modele_du_processeur[]” value=”Core i3″ /> <input type=”checkbox” name=”modele_du_processeur[]” value=”Core i5″ /> <input type=”checkbox” name=”modele_du_processeur[]” value=”Core i7″ /> Once that’s done, you will get an array in $_GET[“modele_du_processeur”], so you can work with $args = array( … Read more
Update custom field on page specific to logged in user
Here is the Code function university_adjust_queries( $query ) { if ( ! is_admin() && is_post_type_archive( ‘program’ ) && $query->is_main_query() ) { $query->set( ‘orderby’, ‘title’ ); $query->set( ‘order’, ‘ASC’ ); $query->set( ‘posts_per_page’, -1 ); } if ( ! is_admin() && is_post_type_archive( ‘event’ ) && $query->is_main_query() ) { $today = date( ‘Ymd’ ); $query->set( ‘meta_key’, ‘event_date’ ); … Read more
Ordering posts by custom fields (Date)
How do I update custom field post meta in frontend post template?
You will first need to add some metaboxes to your posts. This has been answered a lot, and there are many posts on the internet about is, such as this full guide. After adding metaboxes, you can hook into the wp_head action hook and output your metadata. Here’s a simple piece of code that goes … Read more
You could write a function to hook into the display of the title, and then when the title is displayed, it will get the value of the custom field and append it to the title. That way you aren’t editing/changing the title every time you save the post. You could do something like: function append_year( … Read more
You can use the current_user_can() function to test the current user’s role. I would also recommend making the custom field protected by default and allowing access only to the proper users. In theory, something like this should work: function my_exclude_custom_fields( $protected, $meta_key) { if ( in_array( $meta_key, array( ’email’, ‘text’ ) ) ) { if … Read more