How to show a gloabl message on a user profile page (in back end)?

add this code to your function.php <?php function showMessage($message, $errormsg = false) { if ($errormsg) { echo ‘<div id=”message” class=”error”>’; } else { echo ‘<div id=”message” class=”updated fade”>’; } echo “<p><strong>$message</strong></p></div>”; } function showAdminMessages() { showMessage(“This is my message.”, true); } add_action(‘admin_notices’, ‘showAdminMessages’); ?>

How to loop through certain custom field values

Your query seems to be in order except for the fact that you do need to reset your query once done. Simply just add wp_reset_postdata() between endwhile and endif. Failing to do so might lead to other queries being influenced by this query. The opposite is also true, other custom queries can also influence this … Read more

custom field not saved

You are wrong, your custom field is saved but you won’t see the value pre-selected in the select box. To see it you have to set the selected attribute of the select element. You can do it easily with selected() function. You should also escape the attribute values and, in your case, use wp_reset_postdata instead … Read more

wp_query check if integer exists in custom field’s array

First of all, your meta_query is wrong. It should be an array of an array, not just an array So, the following ‘meta_query’ => array ( ‘key’ => ‘qd_resource_author_selector’, ‘value’ => $myAuthor, ), becomes ‘meta_query’ => array ( array( ‘key’ => ‘qd_resource_author_selector’, ‘value’ => $myAuthor, ), ), Secondly, you can optimize your query. You are … Read more

How to display multiple images in custom field

Assuming we are viewing some king of single – post, page, custom post type etc. <?php $imgs_meta = get_post_meta( get_the_ID(), ‘AP_post_image’, true ); if ( ” != $imgs_meta ) { $imgs = explode( ‘,’, $imgs_meta ); foreach ( $imgs as $src ) printf( ‘<img src=”https://wordpress.stackexchange.com/questions/182602/%s” />’, esc_url( $src ) ); }

How to save multiple options from a dropdown in user profile

You will need an opening select tag that tells PHP it is an array. Something along the lines of the following should get you on your way… <?php // Display Fields add_action( ‘show_user_profile’, ‘add_multiple_choice_dropdown ‘ ); add_action( ‘edit_user_profile’, ‘add_multiple_choice_dropdown ‘ ); function add_multiple_choice_dropdown ( $user ) { $current_selections = get_user_meta( $user->ID, ‘multi_dropdown’, true ); ?> … Read more

Admin search ACF relationship

Here is a code snippet that will do what you described: add_action( ‘pre_get_posts’, ‘wpsx_185734_acf_search_relationship’ ); function wpsx_185734_acf_search_relationship( $q ) { $screen = get_current_screen(); $s = $q->get(‘s’); $post_type = $q->get(‘post_type’); // Be very selective when running code at the pre_get_posts hook if ( ! is_admin() || empty( $s ) || ( isset( $screen->post_type ) && ‘story’ … Read more