Storing postID in session variable to query database when visitor on custom template page

If your only need is convert a a permalink structure in a get variable use an endpoint. <?php /** * Plugin Name: Question 112350 Plugin * Author: G.M. */ /** * Add a new role cloning capabilities from editor and flush rewrite rules */ function install_q112350_plugin() { plugin_q112350_endpoint(); flush_rewrite_rules(); } /** * Remove the role … Read more

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