Support » Plugin: WP Job Manager » RSS Feed – Featured Only

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Giannis Karagiannis

    (@gikaragia)

    Hello Eliot,

    if the only change that you want to do is return the featured jobs then you could add a ‘job_feed_args’ filter to expand the query arguments. The arguments that you are looking to add is ‘meta_key’ = _featured and ‘meta_value’ = true. The filter is applied in the job_feed() method.

    Hope this helps,
    Giannis

    Fantastic. So I think the following code will do:

    
    add_filter('job_feed_args', 'featured_feed_query_args');
    
    function featured_feed_query_args($query_args)
    {
    
        $query_args[] = [
            'meta_key' => '_featured',
            'meta_value' => true
        ];
    
        return $query_args;
    }
    

    My next question is, we need a feed of both:

    1. All jobs
    2. Featured jobs

    Any ideas if I can make the featured conditional without rewriting…

    eg.

    1. https://domain.com/?feed=job_feed
    2. https://domain.com/?feed=job_feed&featured

    Thanks!

    Plugin Author Giannis Karagiannis

    (@gikaragia)

    Hello Elliot,

    I think you can achieve this by accessing the _GET global in your filter and add the _featured query_arg only if a specific argument was passed.

    Thanks Giannis – helped a lot and here is the code if anyone else wants to use:

    https://domain.com/?feed=job_feed
    https://domain.com/?feed=job_feed&featured=true

    
    add_filter('job_feed_args', 'featured_feed_query_args');
    
    function featured_feed_query_args($query_args)
    {
    
        // check if featured
        if ($_GET['featured'] == 'true') {
    
            $query_args['meta_query'][] = [
                'key' => '_featured',
                'value' => true,
                'compare' => '='
            ];
    
        }
    
        return $query_args;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.