How do I get the page template name chosen?

I picked the following code from an answer here, https://stackoverflow.com/questions/2544870/remove-main-editor-from-wordpress-edit-page-screen/42093956. I tweaked the code to remove the classic editor on pages using default page template. And added the comments. function remove_editor_init() { $post_id = 0; if ( isset( $_GET[‘post’] ) ) { $post_id = $_GET[‘post’]; } $template_file = get_post_meta( $post_id, ‘_wp_page_template’, TRUE ); // var_dump($template_file) … Read more

Template for landing pages

in your theme folder. create a new php file. For example call it: landingpage.php in the php file you could have something as basic as: <?php /* Template Name: Landing Page */ get_header(); while ( have_posts() ) : the_post(); the_content(); endwhile; get_footer(); ?> Elementor will be called / inserted where it says the_content(); Included out … Read more

Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?

You could consider using the good ol’ get_template_part( string $slug, string $name = null, array $args = array() function, which is a native WP function. Especially now as it supports the third parameter for passing data to the template file (since WP 5.5). Create a function (in your (child) theme functions.php file) that wraps around … Read more

Is there a more efficient way to loop through pages?

Alternative to if… else… you can use the control structure switch functionality. But if you use if… elseif… or switch is mainly a matter of preference. The performance is the same. if else if ($i == 0) { echo “i equals 0”; } elseif ($i == 1) { echo “i equals 1”; } elseif ($i … Read more

WordPress template page name displayed on screen

If your template file doesn’t have the <?php tag at the top, you should add it. <?php /* Template Name: Exhibition – Pilgrims */ …is how the very top of your template file should look. Your sample should read like this. <?php /* Template Name: Exhibition – Pilgrims */ get_header(); ?> <div class=”container fadeIn perimeter”> … Read more

Timber – Twig post.content returns null can’t create ACF Gutenberg blocks

You will need to add the current page object to the timber context using timber_context filter. Something like this add_filter(‘timber_context’, ‘bt_timber_add_to_context’); function bt_timber_add_to_context ($context) { // add current page content $context[‘page’] = Timber::get_post(); return $context; } That’s how I added it in my custom timber theme. Now when you want to get the page content … Read more

What’s a good way to unenqueue all scripts for a single template page?

I haven’t tried it, but this might do it: global $wp_scripts; if (is_a($wp_scripts, ‘WP_Scripts’)) { $wp_scripts->queue = array(); } Basically just resetting the scripts queue to blank. Should work, I think. You’d want this right at the top of your attachment template, probably. From an optimization perspective, it would be faster to use the is_attachment() … Read more