• Resolved Eve

    (@etransac)


    hi,

    is it possible to add a new template?

    i.e template for sold items

    • This topic was modified 8 years, 4 months ago by Eve.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, it is possible but a bit complicated, you can use ‘adverts_load_template’ filter https://wpadverts.com/documentation/child-themes-and-templates/ to load a custom template for single.php file inside new custom file add following code

    
    <?php
    
    if($is_sold) {
        printf( '<div>Custom Template</div>' );
    } else {
        include ADVERTS_PATH . '/templates/list.php';
    }
    

    of course, by default the $is_sold variable does not exist, you need to replace it with your own code which will check if the custom template should be loaded or not.

    Thread Starter Eve

    (@etransac)

    ok noted on that… just wanna share my website link to show how grateful I am for all your support and having us use your fantastic plugin. Thank you from the bottom of my heart.

    Thread Starter Eve

    (@etransac)

    btw marking item sold is still a challenge for me.. i’m looking at making the sold items appear on user’s advert list but not in the advert_list.. if you can try to register in my website and post an ad.. you will know what i mean.

    Plugin Author Greg Winiarski

    (@gwin)

    Thanks for sharing your website, it looks great :).

    You can try adding the code below to your theme functions.php it should hide on [adverts_list] all the ads which have “mark as sold” checked.

    
    add_filter("adverts_list_query", "hide_sold_items");
    function hide_sold_items( $args ) {
        $args["meta_query"][] = array('key'=>'is_sold', 'value'=>1, 'compare'=>'NOT EXISTS');
        return $args;
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘add New template’ is closed to new replies.