Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin

Background & Core Functionality Why a Taxonomy Path Slug Alone Produces a 404 However this slug doesnt work. mysite.com/wiki/help-topics throws a 404. WordPress does not provide a mechanism for “an archive of taxonomy terms” out of the box – that is, neither the template hierarchy nor the WP_Query/WP_Tax_Query logic support a direct display of terms … Read more

How to quickly switch custom post type singular template?

you can do it like this: //add movies_view to query vars add_filter(‘query_vars’, ‘my_query_vars’); function my_query_vars($vars) { // add movies_view to the valid list of variables $new_vars = array(‘movies_view’); $vars = $new_vars + $vars; return $vars; } then add a template redirect based on that query_var: add_action(“template_redirect”, ‘my_template_redirect’); // Template selection function my_template_redirect() { global $wp; … Read more

Different templates for parent and children categories/taxonomies

I suggest creating 3 files 1) regiontemplate-country.php 2) regiontemplate-city.php These 2 will contain the templates for country & city, then 3) taxonomy-region.php In this file, add the code to load the appropriate template <?php $term = get_term_by(‘slug’, get_query_var(‘term’), ‘region’); if((int)$term->parent) get_template_part(‘regiontemplate’, ‘city’); else get_template_part(‘regiontemplate’, ‘country’);

WordPress Template Engine?

Correct, there is no PHP templating engine built into WordPress. This does however give you the flexibility to use a templating engine such as Twig or Blade (and I have worked on sites using each of those), or even completely headless using the REST API.

wp_trim_words() does not trim the_content() in WordPress

The problem lies in this line: <?php echo wp_trim_words( the_content(), 55, $moreLink); ?> You call the_content function in there. This function prints all the content and doesn’t return anything. It means that you print the content, and then pass an empty string to the wp_trim_words. It should be: <?php echo wp_trim_words( get_the_content(), 55, $moreLink); ?> … Read more

Load post with a different template?

you can do it like this: //add my_print to query vars function add_print_query_vars($vars) { // add my_print to the valid list of variables $new_vars = array(‘my_print’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_print_query_vars’); then add a template redirect based on that query_var: add_action(“template_redirect”, ‘my_template_redirect_2322’); // Template selection function my_template_redirect_2322() { global $wp; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)