Hot answers tagged

5

Say if your have header-video.php used for video post format. Replace get_header(); with get_header(get_post_format()); in your regular singular.php or index.php. If WP can find header-video.php it will load it otherwise it will automatically will fallback to header.php.


3

The use of function_exists is a very bad habit that should simply be avoided in favor of using actions and filters. If you want child themes to be able to override some functionality you need to be very specific about which one and how, and function_exists is usually not specific enough for that.


2

Sorry I can not comment yet on this site Could you be removing an action before it is registered? Have you tried wrapping this with an on init hook? Perhaps using remove_filter would be a better choice. function my_init() { remove_filter( 'storefront_header', array( 'Galleria_Structure', 'galleria_top_bar_wrapper' ) ); remove_filter( ...


2

You may want to look at the TwentySixteen theme, which does it this way: In single.php: get_template_part( 'template-parts/content', 'single' ); Several templates are grouped in the 'template-parts' folder. You could use a similar logic for your custom post type. It seems that the technique comes from _underscores.


2

You can not replace the URL in the database using ctrl+f or any other "direct" method. You have to do a search & replace in the whole database in a way capable of keeping the validity of serialized data. There are several tools to do that serialized seach & replace. For example: Plugins like Better Search Replace, Velvet Blues Update URLs or ...


2

Please look up before posting your questions ! There is a detailed answer available. http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php


1

Best way to check the option before setting the permalink is as follows: if ( get_option( 'page_for_posts' ) ) { echo '<a href="'.esc_url(get_permalink( get_option( 'page_for_posts' ) )).'">'.esc_html__( 'Blog', 'textdomain' ).'</a>'; } else { echo '<a href="'.esc_url( home_url( '/' ) ).'">'.esc_html__( 'Blog', 'textdomain' ...


1

Figured it out after thinking it through.. if (stripos(strtolower($template_filename), 'home') !== false) { $results[] = $template_name; }



Only top voted, non community-wiki answers of a minimum length are eligible