Home User profile
tagDiv Member
This user did not write anything. So we are just showing here some random text to make the profile page look nice :)
maxx1985
tagDiv Member

The code was a mess 🙂


static function get_post_meta_array($post_id, $key) {
$lookat=array(
2247=>"single_template_3",
4360=>"single_template_10"
);
$post_meta = get_post_meta($post_id, $key, true);
$category = get_the_category($post_id)[0];
$first_category = $category->term_id;
if (!is_array($post_meta)&&!isset($lookat[$first_category])) {
$post_meta=array();
return $post_meta;
}elseif(!is_array($post_meta)&&isset($lookat[$first_category])){
$post_meta=array();
$post_meta["td_post_template"]=$lookat[$first_category];
return $post_meta;
}
return $post_meta;
}

maxx1985
tagDiv Member

I have the solution for the problem, is a little ”handmade” but it works.
you have to edit the function get_post_meta_array in \includes\wp_booster\td_util.php row 1540 whit this enhanced function:

static function get_post_meta_array($post_id, $key) {
		$lookat=array(
		        //id_category=>"single_template_xx"
			2247=>"single_template_3",
			4360=>"single_template_10"
		);
        $post_meta = get_post_meta($post_id, $key, true);
	$category = get_the_category($post_id)[0];
	$first_category = $category->term_id;
		
        if (!is_array($post_meta)&&!isset($lookat[$first_category])) {
	    $post_meta=array();
            return $post_meta; 
         }elseif(!is_array($post_meta)&&isset($lookat[$first_category])){
            $post_meta=array();
	    $post_meta["td_post_template"]=$lookat[$first_category];
            return $post_meta;
         }
		
        return $post_meta;

    }

You have to populate the array with the association category_id -> post_template, the variables are single_template_1 to single_template_13.
Custom post settings will be maintained.
Hope to be useful

  • This reply was modified 7 years by maxx1985.
  • This reply was modified 7 years by maxx1985.
maxx1985
tagDiv Member

up

Viewing 3 posts - 1 through 3 (of 3 total)