add_action and remove_action if custom field exists

I’m not clear on how your code works as-is, as I mentioned in my comment. It looks like you’re adding an action to call a function inside the function that you want to call with that action. If nothing outside the function invokes it, it never runs. add_action( ‘template_redirect’, ‘check_breadcrumb_condition’ ); function check_breadcrumb_condition(){ global $post; … Read more

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)