I want to split this into two functions

You can separate it into two functions by using following code : <?php add_action(‘tmpl_detail_page_custom_fields_collection’,’custom_fields_colletion’); /* Name : custom_fields_colletion Desc : Return the custom fields collection for detail/single page */ function custom_fields_colletion() { global $wpdb,$post,$detail_post_type; $detail_post_type = $post->post_type; if(isset($_REQUEST[‘pid’]) && $_REQUEST[‘pid’]) { $cus_post_type = get_post_type($_REQUEST[‘pid’]); $PostTypeObject = get_post_type_object($cus_post_type); $PostTypeLabelName = $PostTypeObject->labels->name; $single_pos_id = $_REQUEST[‘pid’]; } else … Read more

Use custom field as tag slug

first get tag slug from your saved meta key my-tag-slug in a variable $tag_slug = (isset(get_post_meta(get_the_ID(), ‘my-tag-slug’, true))) ? get_post_meta(get_the_ID(), ‘my-tag-slug’, true) : null; now query posts by $tag_slug replace showposts with posts_per_page $args = array( ‘tag’ => $tag_slug, ‘posts_per_page’ => 5, ‘caller_get_posts’ => 1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo … 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

Copy url from post_content to custom field

What you need to do is run a function that gets triggered when the “update” button is clicked on posts. I can’t guarantee that my attempt to isolate the shortcode was successful, ( I’m not too good at that stuff ), but you definitely get the idea here! add_action(‘save_post’, ‘save_details’); function save_details() { global $post; … 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)