Hello!
You found the right thing 😉
To expound on that, you can get the primary category like so:
if ( function_exists( 'the_seo_framework' ) ) {
$term = the_seo_framework()->get_primary_term();
}
// Default to WordPress's best effort when no valid term is returned.
if ( empty( $term ) ) {
$cats = get_the_category(); // this returns an array... nice function name :)
if ( $cats ) {
$cats = wp_list_sort(
$cats,
[ 'term_id' => 'ASC' ]
);
$term = $cats[0];
}
}
if ( ! empty( $term ) ) {
// Make breadcrumb item from $term here.
}
I hope this helps! Cheers 🙂
Thank you! But I’m learning php … so if I had to insert everything with the href tag it would be something like that?
if ( function_exists( 'the_seo_framework' ) ) {
$term = the_seo_framework()->get_primary_term();
}
// Default to WordPress's best effort when no valid term is returned.
if ( empty( $term ) ) {
$cats = get_the_category(); // this returns an array... nice function name :)
if ( $cats ) {
$cats = wp_list_sort(
$cats,
[ 'term_id' => 'ASC' ]
);
$term = $cats[0];
}
}
if ( ! empty( $term ) || $portfolio_page_id) {
$breadcrumbs[] = '<a href="'. esc_url(?) .'">'. esc_url(?) .'</a>';
}
How do i get url and name?
Thank you very much, very kind
Yes, I solved it like this:
if ( function_exists( 'the_seo_framework' ) ) {
$term = the_seo_framework()->get_primary_term(get_the_ID(), 'portfolio-types' );
}
if ( empty( $term ) ) {
$cats = get_the_category();
if ( $cats ) {
$cats = wp_list_sort(
$cats,
[ 'term_id' => 'ASC' ]
);
$term = $cats[0];
}
}
if ( ! empty( $term ) || $portfolio_page_id) {
$breadcrumbs[] = '<a href="'. esc_url(get_term_link($term)) .'">'. esc_html($term->name) .'</a>';
}
Thanks for your help!