How to delete attachments associated with custom field type when post property changes? [closed]

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

Pin to Top Functionality using orderby custom field then event date

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

Style Radio Buttons inside Edit Page (Custom Fields)

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

Automatically convert standard posts with custom fields to custom post types

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

WordPress search form and search result through ACF field in custom taxonomy

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

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