Return ACF Field value function
Return ACF Field value function
Return ACF Field value function
You can use the save_post hook. add_action( ‘save_post’, ‘mytheme_my_post_just_updated’ ); function mytheme_my_post_just_updated($post_id){ $deal_type = get_field($post_id, ‘deal_type’); if($deal_type == ‘sold’){ $gallery = get_field($post_id, ‘gallery’);// This bit and the next few lines will depend on how you’ve set up the custom field. // Fast forward a few lines… foreach($images as $image){ // I’m assuming that $images is … Read more
Set the return setting for your ACF field to “Image ID” (instead of “Image URL”). Then in your code: <?php if ( $image_id = get_field( ‘aktuell_titel’ ) ) echo wp_get_attachment_image( $image_id, ‘name_of_custom_size’ );
I had a similar aproach some days ago //….. ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘pin_clause’ = array( ‘meta_key’ => ‘pin_to_top’, ‘meta_type’ => ‘NUMERIC’, ‘meta_value_num’ => ‘1’, ‘compare’ => ‘=’ ) ), array( ‘date_clause’ => array( ‘meta_key’ => ‘_EventStartDate’, ‘meta_type’ => ‘DATETIME’, ‘meta_value’ => ‘$today’, ‘compare’ => ‘>=’ ) ) ), ‘orderby’ => array( … Read more
Add your styles to /your-theme/admin-edit-post.css .inside ul.acf-radio-list.radio.horizontal li label { /* styles… */ } Then enqueue the styles by adding this to your theme’s functions.php: function wpse250000_admin_styles( $hook ) { // Bail if we’re not on the post.php admin page if ( ‘post.php’ !== $hook ) { return; } // Ensure we’re looking at a … Read more
You can add the post ID in the user meta, which is like a space in database to save contents related to an user and a key (the name of the field you’re saving). Then, each time you show that post, you can check if the user meta contains the ID of it, and you … Read more
The question: what is the easiest way to convert standard posts with custom fields into a new custom post type There’s no “easy” way. Consider that all posts have custom fields (some are hidden, and WordPress will add them). So you would need to convert post types based on the presence / value of specific … Read more
I figured it out using a While loop and an If statement with a counter. This solution uses functions from Advanced Custom Fields; $i = 0; while have_rows(‘week_rows’) ): the_row(); $i++; if( $i == 5 ) { // stops on the 5th row of ‘week_rows’ array break; } endwhile; // I had to move the … Read more
This should hopefully help you on your way, although I’ve not fully tested it… The basic search form here which will load the site_url() with appended search query string. You should change this to better reflect your site layout such as <?php site_url( ‘search’ ); ?> (‘http://website.com/search‘). Place the Results page code within the results … Read more
I’m typically against using a bunch of plugins, but an option for you is to use the Relevanssi plugin. I use it along side ACF and allows you to search within those fields. If you decide to use it, after installation/activation, go to the setting page for the plugin and scroll down to the “Indexing … Read more