Instead of using page templates to define layouts, define layouts using custom post meta. The custom post meta can then be shown or not shown using is_plugin_active()
.
If you’re going to define the page template itself in the Theme, then you’re pretty much stuck with doing something like determining if the Plugin is active (which, on the front end, should be done using a function_exists()
conditional or something similar), and including the default template if not. For example:
/**
* Template Name: Shop
*/
if ( ! function_exists( 'some-woocommerce-function' ) ) {
get_template_part( 'page' );
} else {
// Shop template markup goes here
}
That way, even if the template is selected, it will gracefully degrade.
Related Posts:
- Check if a menu is empty?
- page template for attachement page?
- Showing content from one page on another
- Populate editor with some content of a page with a page template
- WooCommerce Tabs [closed]
- Inject class in body when particular page template is used
- Adding wrapper elements in the_date() like in the_title()?
- Show meta box only for default page template
- Contain multiple page templates in one PHP custom template file in WordPress?
- remove_action() not working in page template – Genesis
- Calling PHP function doesn’t work in index.php
- Display custom meta box in my template file
- Loop on a wordpress Page instead of content coming from the WP text editor
- start_lvl Ignored in Custom walker_nav_menu
- Enforcing password complexity
- How do I make my function add variables/values to the $post object?
- Calculate percentage of post by category
- Dynamically change feature image in customiser
- Change comments form title on a page by page basis
- Creating wordpress user registration form
- Get the title before comma
- category not display in word press grammatically
- Getting a fatal error while updating
- “Can’t use function return value in write context” error
- Display 4 chronological posts starting with a random post
- my function doesn’t return my post from today
- Warning: array_pop() expects parameter 1 to be array, boolean given
- How to break down importing of feeds
- How to enqueue CSS and JS only on specific template?
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Use wp_get_recent_posts with search term
- Run a filter when a walker runs
- Woocommerce Attributes pulling in wrong data
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Display fields as values in array from external SQL DB
- Passing the custom field values in the wp_get_current_user array function
- Edit Yoast SEO breadcrumbs output [closed]
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- What’s the uses of wp_cache_set() or wp_cache_add()?
- How to create a php variable using WordPress the_title() function
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- Best way to use a large array in function
- Setting user nickname and displayname to shortened email
- Download PDF after CF7 form submission
- ::before on open/close function [closed]
- REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead
- How to check if a PHP string is different than meta field?
- Creating a mobile site by adding a new class to the body tag from functions.php
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Issue with fetching mysql data and displaying results via shortcode in webpage
- Plugin onclick button activate other plugin
- Noindex Posts From Certain Authors In WordPress
- How do I create a function that modifies a message in the wp-login.php file?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Show all tags within a category?
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Unable to Call More than One Meta Box Output
- Make a page (url) not cacheable [closed]
- How can I alter this code to accept a slug as well as an ID?
- Enqueueing a code block from an options framework
- SQL error with custom query
- How to change basename url for wp-admin?
- Prevent header and footer from loading on specific pages with template or plugin
- How to exclude meta no index pages from wp_list_pages
- Products listing check if meta checkbox is checked
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Get Shortcode output to database for static post_content
- Edit a function to take different actions based on user role
- How to put 2 php codes in functions.php without site crashing
- Using Javascript On Page – Header and Footer Now Missing
- Unzip_file causing Media file upload error
- How to add a full working piece of website already coded, to a large scale Website design project?
- WP HTTP API call response
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Escaping a Single Quote in str_replace for Nav Function
- Private messaging – Getting and displaying the avatar/url of a message recipient
- insert thumbnail image from php script
- Find all strings between an enclosing shortcode
- Trying to see if page is category or single and displaying title with appropriate heading tag
- How can I put a custom field as the link of a button shortcode?
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- WordPress: Create A Widget to Accompany Plugin
- Fix My Custom Function: Remove Automatic
- WP Debug enabled Undefined index error in a widget
- PHP Creating a formula from mysql db values and db stored math operator
- Generate and upload screenshot as featured image for user-submitted post
- a problem in class in class-wp-hook.php