• Resolved sulive

    (@sulive)


    Hi,

    I have noticed that the categories that WPAdverts use are different than the default categories of WordPress.

    Suppose that I have blog and I would like to add a WPAdvert category to it, so this message will also show, how do I that?

    Thanks

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

    (@gwin)

    I am not sure what exactly are you trying to do?

    If you would like the [adverts_add] form to assign the Ads to default WordPress categories, then this is possible but will require quite a lot of custom programming to integrate WPAdverts with default categories.

    Thread Starter sulive

    (@sulive)

    Well, we have some offline ads from a newspaper that we would also like to include on our site.
    So I was wondering whether I could add those offline ads as posts and attach a WPAdverts category to it. So when we use [adverts_list] these offline ads will show also.

    Thanks!

    Plugin Author Greg Winiarski

    (@gwin)

    This will not work i am afraid, as when the [adverts_list] queries DB for the Ads it is looking for posts with post_type = “advert” so any other post would be ignored.

    You could modify the query to include post types: advert and post, but then all of the posts will be shown in the [adverts_list].

    Thread Starter sulive

    (@sulive)

    Ok, which query do we have to modify?

    So when we have a list of the WP Advert categories like: Cars, would also like to show the posts that have WP category Cars

    Thanks
    Silvia

    Plugin Author Greg Winiarski

    (@gwin)

    You can modify the query using adverts_list_query filter

    
    add_filter( "adverts_list_query", "my_adverts_list_query" );
    function my_adverts_list_query( $args ) {
        $args["post_type"] = array( "advert", "post" );
        return $args;
    }
    

    This will just include the posts in the ads list, if you need to further fine tune the query you can do it inside the my_adverts_list_query function. The $args variable contains params that will be passed to WP_Query https://codex.www.ads-software.com/Class_Reference/WP_Query

    Thread Starter sulive

    (@sulive)

    Hi Greg,

    I have added some categories as WP adverts categories like Cars, Houses, etc.
    I have also added regular WP categories like: Cars_Paper, Houses_Paper

    So suppose someone clicks on a WP adverts category: https://www.xyz.com/advert-category/cars/
    I would like to first have the Featured ads displayed and the WP adverts of that category (this is already the case).
    And after these ads, the newspaper ads, with car ads of WP category Cars_Paper.

    How would the query look like and in which file(s) do I have to modify the query?

    Thanks,
    Silvia

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, the best way to do that would be to create a taxonomy-advert_category.php file as explained here https://wpadverts.com/documentation/child-themes-and-templates/ in section “Custom Taxonomy Template”, and instead of last code snippet

    
    <?php 
        global $wp_query;
        remove_filter("the_content", "adverts_the_content");
        echo shortcode_adverts_list(array(
            "category" => $wp_query->get_queried_object_id()
         ));
     ?>
    

    You will need some custom code which will list first the featured ads, then your ads and finally at the end the normal Ads.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Category of WPAdverts different than default categories’ is closed to new replies.