Ways to have multiple front-page.php templates that can be swapped out?

One way is to have a single front-page.php and then using get_template_part(), to show different content based on user choice. Rough code: get_header(); $layout = get_option( ‘front_page_layout’, ‘default’ ); get_template_part( ‘front-page’, $layout ); get_footer(); After that you need to create a file for every layout, they should be called, something like: front-page-one.php front-page-two.php front-page-three.php front-page-default.php … Read more

Overwrite theme file from plugin

WordPress way (recommended): In your plugin, use the WordPress theme_file_path filter hook to change the file from the plugin. Use the following CODE in your plugin: add_filter( ‘theme_file_path’, ‘wpse_258026_modify_theme_include_file’, 20, 2 ); function wpse_258026_modify_theme_include_file( $path, $file=”” ) { if( ‘includes/example-file.php’ === $file ) { // change path here as required return plugin_dir_path( __FILE__ ) . … Read more

tag.php doesn’t work with tags on a custom post type post?

If this is related to your other question, what you’ve got is a custom taxonomy, so you need either a taxonomy-{taxonomy}.php template (in your case taxonomy-article_topics.php), or just a more general taxonomy.php template. (also, go back and accept answers to your other questions here if they’ve been solved!) UPDATE sorry, misunderstood your question- add this … Read more

Template issues getting ajax search results

When you load a template file directly that way, you’re not loading the WordPress environment, so no WordPress functions are available. Your two options are to either load the search page on the front end and filter the result, like: $(‘#results’).load(‘http://mysite.com/?s=searchterm ul#target’); Or build a search function using WordPress provided AJAX functionality, see AJAX in … Read more

How to add a ” waiting” icon for an ajax in WP frontend?

You can use the inbuilt spinner class : Add the class to the HTML where you want the spinner to appear, for example after your search button : <button type=”button” id=”searchsubmit”>Search Button</button> <span class=”spinner”></span> <!– Add this spinner class where you want it to appear–> In jQuery you should add the is-active class to the … Read more

Custom templates folder

As of WordPress 3.4 you can put your page templates in whatever direct subdirectory you need, it doesn’t sound like you can put them into sub-sub directories but I haven’t tested this. I suggest storing templates into /page-templates/ folder as WordPress seems to recognize it. From WordPress Page Templates Entry: WordPress recognizes the subfolder page-templates. … Read more