单独

发布时间:2023-12-25 13:19:41
 public function custom_posttype_link( $link, $post = 0 )
    {
    	$a = $this->ttax;//用在内容URL上的分类法
		$b = $this->ttype; //posttype
		

		if ( $post->post_type == $b ){
			$t_terms = wp_get_post_terms($post->ID,$a);
			if ( !empty($t_terms) && !is_wp_error($t_terms) ) {
				$term_slug = $t_terms[0]->slug.'/';
				$term_fuid = $t_terms[0]->parent;
				if ( $term_fuid != 0 ) {
					$t_term_s1 = get_term_parents_list( $term_fuid, $a, array( 'format'    => 'slug','separator' => '/', 'link' => false,'inclusive' => true,) );
					if ( !empty($t_term_s1) && !is_wp_error($t_term_s1) ) {
						$term_slug = $t_term_s1.$term_slug;
					}
				}
			}
			$link = home_url( $term_slug . $post->ID .'.html' );
		}

    	return $link; 	
    }