Using PHP to read WordPress Posts
I think that you are looking for the function get_post_status Example: if (get_post_status($postid)==’publish’) echo date_i18n( $date_format, strtotime( $expiration_date ) );
I think that you are looking for the function get_post_status Example: if (get_post_status($postid)==’publish’) echo date_i18n( $date_format, strtotime( $expiration_date ) );
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
With ACF, in the same repeater custom field that your departure date uses, add a price field. Then each time you add a departure date, you can add the associated price. Wherever you’re showing the departure date in the template you can add the price field as well.
You can make use of get_post to get the post objects of a given post. This will be unfiltered objects, so you would want to make use of apply_filters and the appropriate filters described in the linked page. If you need to get info from a custom field, whether native custom fields of ACF fields, … Read more
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’); ?>
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
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
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 ) ); }
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
I finally figured this out. The Custom Meta Boxes and Fields plugin has a sanitize setting where you can add your own sanitize function or use one of the default wordpress sanitize functions. In my case, WordPress already has a sanitize function that does exactly what I wanted. See the code below, specifically the line … Read more