• Resolved johndoe01

    (@johndoe01)


    Greetings.

    I’m having a small issue. I have several customized list views for several sections on the site. But the loaded on the site is the corresponding to the default one.

    Since i have made changes on the list view, now it is showing the default list view… with the additional material that should not be seen there like the side menu and the carousel.

    I change to the vanilla list.php but i lose those items on the category view.
    How can i make that category view shows with my customizations and the profile view’s ads shows with the vanilla list?

    Because i change here but i’m not sure how can I ensure that the vanilla list.php file only loads on the Profile view?

    Thanks in advance.

    add_action("adverts_template_load", "custom_category_list");
    function custom_category_list( $tpl ) {
        // $tpl is an absolute path to a file, for example
        // /home/simpliko/public_html/wp-content/plugins/wpadverts/templates/list.php
        
        $basename = basename( $tpl );
        // $basename is just a filename for example list.php
         
         if( $basename == "list.php" ) {
            // return path to list.php file in custom-list-template directory
            return dirname( __FILE__ ) . "/list.php";
         } else {
            return $tpl;
         }
    }
    • This topic was modified 5 years, 3 months ago by johndoe01.
    • This topic was modified 5 years, 3 months ago by johndoe01.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter johndoe01

    (@johndoe01)

    I’m a bit close to what i need. I found on the wpadverts authors the template and in the authors.php around line 59 is

        <?php do_action( "adverts_authors_content", $post_id, $author_id, $action ) ?>
    

    The only thing is making that a list file, either the vanilla one or a custom one loads and is different from the designated main list file.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    so if i understand correctly you would like to have:
    – custom list.php here https://www.racertrader.com/tests/advert-author/cheap-racer/
    – default/vanilla list.php here https://www.racertrader.com/tests/search-results/

    You should be able to do that by changing the line

    
    if( $basename == "list.php" ) {
    

    to

    
    if( is_singular( 'advert-author' ) && $basename == "list.php" ) {
    
    Thread Starter johndoe01

    (@johndoe01)

    Thanks Greg!
    This is exactly what i was looking for.
    Although the email notification went to Spam, i went hiding via CSS which is a SEO Nightmare. When i reached the result through that method i then saw this reply. And undo the CSS settings and added the vanilla list through the proposed method and now works as intended.

    Luckily i kept the custom under another name and kept the list.php file as the vanilla file.

    Now the results are shown as intended.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    ok great, i am glad you have it resolved :).

    Thread Starter johndoe01

    (@johndoe01)

    Well joy didn’t lasted long. Now i came back to square one. Once i removed the CSS changes i did, despite the Vanilla is properly configured, still doesn’t show. here are both blocks.

    
    add_action("adverts_template_load", "custom_category_list");
    function custom_category_list( $tpl ) {
        // $tpl is an absolute path to a file, for example
        // /home/simpliko/public_html/wp-content/plugins/wpadverts/templates/list.php
        
        $basename = basename( $tpl );
        // $basename is just a filename for example list.php
         
         if( $basename == "list.php" ) {
            // return path to list.php file in custom-list-template directory
            return dirname( __FILE__ ) . "/list-main.php";
         } else {
            return $tpl;
         }
    }
    
    add_action("adverts_template_load", "vanilla_list");
    function vanilla_list( $tpl ) {
        // $tpl is an absolute path to a file, for example
        // /home/simpliko/public_html/wp-content/plugins/wpadverts/templates/list.php
        
        $basename = basename( $tpl );
        // $basename is just a filename for example list.php
         
        if( is_singular( 'advert-author' ) && $basename == "list.php" )  {
            // return path to list.php file in custom-list-template directory
            return dirname( __FILE__ ) . "/list.php";
         } else {
            return $tpl;
         }
    }
    

    Now i’m scratching my head to see what I did wrong.

    Thread Starter johndoe01

    (@johndoe01)

    HERE IS the issue.

    The custom List (list.php) on the first block goes correctly.
    The Default list MUST be renamed (my case vanilla-list.php), ergo:

    
    add_action("adverts_template_load", "custom_category_list");
    function custom_category_list( $tpl ) {
        // $tpl is an absolute path to a file, for example
        // /home/simpliko/public_html/wp-content/plugins/wpadverts/templates/list.php
        
        $basename = basename( $tpl );
        // $basename is just a filename for example list.php
         
         if( $basename == "list.php" ) {
            // return path to list.php file in custom-list-template directory
            return dirname( __FILE__ ) . "/list.php";
         } else {
            return $tpl;
         }
    }
    
    add_action("adverts_template_load", "vanilla_list");
    function vanilla_list( $tpl ) {
        // $tpl is an absolute path to a file, for example
        // /home/simpliko/public_html/wp-content/plugins/wpadverts/templates/list.php
        
        $basename = basename( $tpl );
        // $basename is just a filename for example list.php
         
        if( is_singular( 'advert-author' ) && $basename == "list.php" )  {
            // return path to list.php file in custom-list-template directory
            return dirname( __FILE__ ) . "/vanilla-list.php";
         } else {
            return $tpl;
         }
    }
    
    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    thanks for the update, you are 100% correct the file name needs to be changed otherwise it is always the same file being loaded, either way, I did not notice that earlier.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Author View + Custom List View.’ is closed to new replies.