Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy Entire Template Folder and Make Editable Version #586

Closed
casbboy opened this issue Dec 15, 2016 · 2 comments
Closed

Copy Entire Template Folder and Make Editable Version #586

casbboy opened this issue Dec 15, 2016 · 2 comments

Comments

@casbboy
Copy link

casbboy commented Dec 15, 2016

So we have this to give url for new style.php:

add_filter( 'amp_post_template_file', 'xyz_amp_set_custom_template', 10, 3 );

function xyz_amp_set_custom_template( $file, $type, $post ) {
    if ( 'style' === $type ) {
        $file = dirname( __FILE__ ) . '/amp/style.php';
    }
    return $file;
}

What if I also wanted to move header-bar.php, footer.php, single.php, meta-time.php, meta-author.php, featured-image.php and all the rest of the files in the "template" folder so I can edit them without risk of overwrite.

I'm just guessing but something like:

add_filter( 'amp_post_template_file', 'xyz_amp_set_custom_template', 10, 3 );

function xyz_amp_set_custom_template( $file, $type, $post ) {
    if ( 'single' === $type ) {
        $file = dirname( __FILE__ ) . '/amp/single.php';
    }
    return $file;
}

and then

add_filter( 'amp_post_template_file', 'xyz_amp_set_custom_template', 10, 3 );

function xyz_amp_set_custom_template( $file, $type, $post ) {
    if ( 'footer' === $type ) {
        $file = dirname( __FILE__ ) . '/amp/footer.php';
    }
    return $file;
}

Something like that? Would like to just reference the editable directory in my functions file for all these template files.

Can I just edit something to point to change location of entire template folder, to point to the same files that I'm editing?

Cheers!
Ryan

@jery61007
Copy link

Actually you could install earlier version of the AMP plugin and create custom template... in the older version the plugin doesn't use several templates for each part of the page like footer and header, instead, almost all main codes are in single file.... here is a tutorial on customizing wordpress AMP pages ... just follow the tutorial and you can update the plugin to the latest version once you finish the customization with the early version ...

Thanks

@mjangda
Copy link
Contributor

mjangda commented Dec 22, 2016

Can I just edit something to point to change location of entire template folder, to point to the same files that I'm editing?

Two options (remove any existing filters for template overrides you already have first):

  • In your theme, add a folder called amp and put your templates there.
  • Hook in to the amp_post_template_dir filter and pass in a path of your choice where your template files live.

@mjangda mjangda closed this as completed Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants