Copying custom field value in to title

Try this: add_action(‘init’, ‘replace_title_logic’); function replace_title_logic() { add_filter(‘wp_insert_post_data’, ‘replace_title_before_update’, 20, 2); add_action(‘wp_insert_post’, ‘replace_title_after_save’, 20, 2); add_filter(‘wp_insert_post_empty_content’, ‘allow_empty_content_for_listing’, 20 , 2); } function replace_title_before_update( $data, $postarr ) { if ( is_int($postarr[‘ID’]) && ($data[‘post_type’] == ‘listing’) ) { $custom = get_post_meta($postarr[‘ID’], ‘ref._nr.’, true ); if ( $custom && ( $custom != $data[‘post_title’] ) ) $data[‘post_title’] = $custom; … Read more

Advanced Custom Field User Help URL

I have this exact thing working on a current project. Here’s the code: <div class=”photo-feature” style=”background: url(<?php the_field(‘the-image’, $page->ID) ;?>) no-repeat center center; “></div> Keep in mind a couple of things: You may need to use $post->ID or $page->ID if you’re using a custom query. Make sure you’re not overriding your background CSS anywhere else … Read more

Advanced Custom Fields repeter field expiration

Possibly better than strtotime, as you already know the date format would be date_create_from_format(). Something like: $course_start = date_create_from_format(‘dmY’,$row[‘start_date’]); if ($course_start > date(‘dmY’)){ echo ‘<tr>’; echo ‘<td>’ . $i . ‘</td>’; echo ‘<td>’ . $row[‘start_date’] ; // Check, if “end_date” field is not empty if( $row[‘end_date’]) { echo ‘ – ‘ . $row[‘end_date’] . ‘</td>’; … Read more

Fetch data from a WP page with same name as current username

According with docs, when you want to retrieve field attached to post using get_field / the_field you should pass a numeric ID as 2nd argument. You are passing a string. So your code should work if: $login = wp_get_current_user()->user_login; $page = $login ? get_page_by_path( $login ) : false; $field = $page ? get_field(‘my_custom_field’, $page->ID) : … Read more

If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?

For all intents and purposes, you only need one loop. While s_ha_dum’s comment is correct, odds are since you’re asking this question, you won’t have a need for multiple loops. <? get_header(); ?> <? if(have_posts()): while(have_posts()): the_post(); ?> <!–Your content here, like so–> <div id=”content”> <? the_field(‘body_content’); ?> <? the_field(‘footer_content’); ?> </div> <? endwhile; endif; … Read more

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