Custom Taxonomy List links being re-written

After taking @Milo ‘s comments into consideration, I removed the s= argument from the link, and it worked!

This is my final code:

function job_listing_taxonomy_list( $taxonomy,$hide ) {
    $args = array('order'=>'ASC','hide_empty'=>$hide);
    $terms = get_terms( $taxonomy, $args );
    if ( $terms ) {
        printf( '<ul name="%s">', esc_attr( $taxonomy ) );
        foreach ( $terms as $term ) {
            printf( '<li><a href="https://wordpress.stackexchange.com/questions/125148/%s/?".$taxonomy.'=%s">%s</a></li>', site_url() ,esc_attr( $term->slug ), esc_html( $term->name ) );
        }
        print( '</ul>' );
    }
}

The difference is that I removed the s= argument, and added site_url() as well so that I don’t have to change it when the site is moved to the live server.

The only reason I had the s= there in the first place, was because I was adapting the search URL from my search bar, and so in my lack of understanding I assumed that it needed the s= there in order to function. Evidently not!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)