How to check active theme is parent or child wordpress
I try this code and it solve my problem if ( is_child_theme() === false ) { // files moved } else { // do nothing } Thankx to @birgire
I try this code and it solve my problem if ( is_child_theme() === false ) { // files moved } else { // do nothing } Thankx to @birgire
Here is a fairly simple approach I was able to get working within a plugin. You’ll want to reference https://developer.wordpress.org/reference/hooks/theme_page_templates/ and https://developer.wordpress.org/reference/hooks/template_include/ as you review the code below. <?php //Add our custom template to the admin’s templates dropdown add_filter( ‘theme_page_templates’, ‘pluginname_template_as_option’, 10, 3 ); function pluginname_template_as_option( $page_templates, $theme, $post ){ $page_templates[‘template-landing.php’] = ‘Example Landing Page’; … Read more
The is_page_template() function is the incorrect function to use in this case as it checks against Page Templates and single.php is just a normal template, not a page specific one, usually meant for posts. The function you’re probably looking to use instead is is_single( $optional_posttype ) which will look for singular view of a post … Read more
Page templates can be stored within the page-templates or templates subdirectory within a theme, but this does not apply to custom post type or taxonomy templates. Fortunately, the template_include filter can be used to change the template that will be loaded. In the example below, template files are stored in the /theme-name/templates/ directory. /** * … Read more
I use a plugin called Query Monitor, that does a whole bunch of stuff, including showing the page’s template. It’s in the WordPress Repo.
If it is a strict structure, you might be better off creating a custom post type. You would then store the name in the title field, the image as the featured image, and the “About” would be the main content. If you need extra information, you can use custom fields (with a plugin to style … Read more
Anywhere in your script, you can define a global variable as follow: Using the superglobal $GLOBALS array. This array is predefined by PHP, and is available in all scopes. It’s an associate array, containing all global variables as a key-value pair. ie: the key will be the variable name, and value will be the value … Read more
This doesn’t work the way you think it does because get_pages doesn’t do what you think it does. First, understand that all pages, all content, in WordPress is really a “post”. A “Page” is just a special type of post. Now, in a normal environment, you wouldn’t call “get_” anything. This is why you’re confused, … Read more
alternative to using the default loop in the front-page.php template: if( have_posts() ) { while( have_posts() ) { the_post(); the_content(); } } you could try using: if( get_option( ‘page_on_front’ ) ) { echo apply_filters( ‘the_content’, get_post( get_option( ‘page_on_front’ ) )->post_content ); } https://codex.wordpress.org/Option_Reference
You are seeing this error because you are requireing the file with a relative path. As @Mark Kapulun pointed out in the comments you should not use relative paths when requireing files. Instead you want to be explicit and use absolute paths. Use get_template_directory() which returns the Absolute path to the directory of the current … Read more