• Resolved 5vvo8jvod6

    (@5vvo8jvod6)


    Hi, currently 301 redirect for expired ads can only be set to one url.

    Is there any way to redirect to adverts_list based on expired ads’ category?

    For example:

    Ad 123 have category ‘baby’. When its expired it should be redirected to adverts_list which show ads only for baby category or we can just redirect to category page for ‘baby’

Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    you can redirect the user to a different URL than the one set in the configuration using the “adverts_redirect_expired_url” filter, for example in order to send the user to a category page to which the Ad was assigned you can use the below code in your theme functions.php file.

    
    add_filter( "adverts_redirect_expired_url", function( $url ) {
        $terms = wp_get_post_terms( get_the_ID(), 'advert_category' );
        if( is_array( $terms ) && isset( $terms[0] ) ) {
            $url = get_term_link( $terms[0]->term_id );
        }
        return $url;
    });
    
Viewing 1 replies (of 1 total)

The topic ‘301 category redirect’ is closed to new replies.