Can anyone clarify why this function is filtering all terms in the highlight
taxonomy, but not filtering for the subscribe-win
term?
Neither $term->term_id
or $term->slug
are working.
I don't get any errors and it is only filtering highlight
- and not other taxonomies.
Thanks!
add_filter( 'term_link', 'slick_term_to_page', 10, 3 );
function slick_term_to_page( $url, $term, $taxonomy ) {
if ( $taxonomy != 'highlight' && $term->term_id != 42 ) :
// if ( $taxonomy != 'highlight' && $term->slug != 'subscribe-win' ) :
return $url;
else :
$url = home_url( '/win' );
return $url;
endif;
}
Can anyone clarify why this function is filtering all terms in the highlight
taxonomy, but not filtering for the subscribe-win
term?
Neither $term->term_id
or $term->slug
are working.
I don't get any errors and it is only filtering highlight
- and not other taxonomies.
Thanks!
add_filter( 'term_link', 'slick_term_to_page', 10, 3 );
function slick_term_to_page( $url, $term, $taxonomy ) {
if ( $taxonomy != 'highlight' && $term->term_id != 42 ) :
// if ( $taxonomy != 'highlight' && $term->slug != 'subscribe-win' ) :
return $url;
else :
$url = home_url( '/win' );
return $url;
endif;
}
Share
Improve this question
asked Jun 19, 2019 at 20:20
user145691user145691
5
|
1 Answer
Reset to default 1Thanks Lucas! I found this code as an example in several places ... still interesting that the &&
doesn't work ... but this does :)
add_filter( 'term_link', 'slick_term_to_page', 10, 3 );
function slick_term_to_page( $url, $term, $taxonomy ) {
if ( $term->term_id != 42 ) :
// if ( $taxonomy != 'highlight' && $term->term_id != 42 ) :
// if ( $taxonomy != 'highlight' && $term->slug != 'subscribe-win' ) :
return $url;
else :
$url = home_url( '/win' );
return $url;
endif;
}
highlight
is the taxonomy.subscribe-win
is a term inhighlight
.42
is theterm_id
.... this filter should isolate the42
but is not ... it's applying to every term inhighlight
. – user145691 Commented Jun 19, 2019 at 20:42susbscribe-win
term they are taken to thewin
page - which is using a custompage
template - and not anarchive
template ... Why, you ask? Because I wantpage
features like comments and social sharing ... Thanks again! – user145691 Commented Jun 19, 2019 at 21:11