• Resolved Sarah Lewis

    (@bookchiq)


    I have a client who’d like to have an RSS feed of the classified ads. Normally this is trivial with a Custom Post Type, but when I use the URL that should work [https://example.com/feed/?post_type=advert], the adverts_disable_default_archive() function redirects the request to the ads list page.

    I believe fixing this behavior is fairly straightforward. I’ve edited line 1752 of wpadverts/includes/functions.php like so:

    if(
        is_post_type_archive( "advert" ) &&
        ! is_feed()
    )

    Would you be willing to update the plugin with this change?

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

    (@gwin)

    Hi, right now i cannot tell if this will be added to the core version, so instead of modifying original files i would recommend replacing the adverts_disable_default_archive with your own function

    
    add_action("init", "my_init", 20);
    function my_init() {
        remove_action('template_redirect', 'adverts_disable_default_archive');
        add_action('template_redirect', 'my_disable_default_archive');
    }
    function my_disable_default_archive() {
        if(is_post_type_archive( "advert" ) && ! is_feed()) {
            wp_redirect( get_permalink( adverts_config( "ads_list_id" ) ) );
            exit;
        }
    }
    
    Thread Starter Sarah Lewis

    (@bookchiq)

    That’ll work for us. Thanks for your help!

    Hello,
    so what have we to do to get an rss feed?

    Thanks for helping!

    Greetings

    Klaus

    • This reply was modified 7 years, 2 months ago by klausharms.
    Plugin Author Greg Winiarski

    (@gwin)

    Just add the above code to your theme functions.php file and you will have the WPAdverts feeds available at https://example.com/feed/?post_type=advert

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘RSS feed being redirected by adverts_disable_default_archive()’ is closed to new replies.