How to use same theme template for multiple taxonomy terms?

You prepare templates (staying with your example): content-redfruits.php, content-greenfruits.php, content-fruits.php. Then in taxonomy file taxonomy-fruit.php (copy and rename taxonomy.php or index.php), before main loop check the term slug of the currently-queried object. $red_templ = [‘strawberries’, ‘tomatoes’, ‘raspberries’]; // term slugs $green_templ = [‘watermelons’, ‘apples’, ‘kiwi’]; // term slugs $template=”fruits”; $obj = get_queried_object(); if ( $obj … Read more

Why is there no global function in wordpress to return the output of any function call?

In direct response to the question, WordPress does not include a function for this partly because it does not specifically apply to WordPress functionality. I.e. it’s a PHP (potential) problem, not WordPress. Also, I wouldn’t say it’s WordPress’ responsibility to provide workarounds for plugins etc that don’t provide an function to return data (which is … Read more

Is it mandatory to have a link to the theme designer?

It depends on the license under which the Theme is released. Assuming the Theme was released under GPL: no; you are free to change the Theme in any way you want. If you redistribute the Theme, modified or unmodified, you are required to maintain the original copyright/license information in the Theme file headers, but are … Read more

What is the first file wordpress looks at in a theme?

If it’s the home page, WordPress will look for the following files in this order and use the first one it finds: 1. front-page.php 2. home.php 3. index.php WordPress template hierarchy is described in detail here: https://developer.wordpress.org/themes/basics/template-hierarchy/ This article explains how WordPress determines which template file(s) to use on individual pages. If you want to … Read more

How to get Ajax into a theme – without writing a plugin?

Put those add_action functions in your functions.php file too. If they’re in header.php, WordPress never registers them since header isn’t loaded in AJAX. Also, you don’t need that is_admin() check. The theme’s header will never load in admin. So, your functions file should look like this: add_action(‘wp_ajax_my_special_action’, ‘my_action_callback’); add_action(‘wp_ajax_nopriv_my_special_action’, ‘my_action_callback’); function my_action_callback() { $whatever = … Read more