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

    (@gwin)

    Hi,
    hmm i am testing this code snippet right now and it is overwriting the single.php correctly.

    What page are you looking at when trying to overwrite the single.php? You should be looking at Advert details page (for example https://demo.wpadverts.com/lite/advert/rayman-legends/).

    Thread Starter marvix2018

    (@marvix2018)

    It was W3 plugin issue.
    I change the path of the file, I created new them in the themes root to avoid file deletion on theme update.

    function override_templates( $tpl ) {
    //echo get_theme_root() . "/wpadverts/";
    
        $dirs = array();
        // first check in child-theme directory
        $dirs[] = get_stylesheet_directory() . "/wpadverts/";
        // next check in parent theme directory
        $dirs[] = get_theme_root() . "/wpadverts/";
        // if nothing else use default template
        $dirs[] = ADVERTS_PATH . "/templates/";
        // use absolute path in case the full path to the file was passed
        $dirs[] = dirname( $tpl ) . '/';
        $basename = basename( $tpl );
        foreach($dirs as $dir) {
            if( file_exists( $dir . $basename ) ) {
                return $dir . $basename;
            }
        }
    }

    Thanks,

    Thread Starter marvix2018

    (@marvix2018)

    Marking this as resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to override single.php?’ is closed to new replies.