WordPress Ignoring My Custom Post Type Templates?

Got it. I had tried to use flush_rewrite_rules() on plugin activation/deactivation, as so: function creativeworks_activate() { // register taxonomies/post types here flush_rewrite_rules(); } function creativeworks_deactivate() { flush_rewrite_rules(); } register_activation_hook( __FILE__, ‘creativeworks_activate’ ); register_deactivation_hook( __FILE__, ‘creativeworks_deactivate’ ); …but that didn’t seem to do anything. However, when I changed the site-wide permalink options arbitrarily and saved them, … Read more

Template Hierarchy tag-{slug}.php directory

When you look at the source code, the tag template is loaded as follow in template hierarchy elseif ( is_tag() && $template = get_tag_template() ) : in wp-includes/template-loader.php get_tag_template() uses get_query_template() which uses locate_template() which loads the tag template according to hierarchy from the theme root folder So, moving your templates to a sub-folder will … Read more

Simple way to get two language WP site

You can use below code for translating strings: add_filter(‘gettext’, ‘translate_text’); add_filter(‘ngettext’, ‘translate_text’); function translate_text($translated) { $translated = str_ireplace(‘Choose an option’, ‘Select’, $translated); $translated = str_ireplace(‘Original Text’, ‘Your Replacment Text’, $translated); return $translated; } But I have no idea for translating complex contents. I know you don’t want to use plugins but as my research, we … Read more

Is there any way to get all the name or slug of template parts used in a page?

You could filter the include paths returned by get_included_files by removing any files from the list that are not in your theme (and/or child theme) directory: function get_theme_includes() { $includedfiles = get_included_files(); // normalize theme paths for matching $styledir = str_replace(“\\”,”https://wordpress.stackexchange.com/”,get_stylesheet_directory()); $templatedir = str_replace(“\\”,”https://wordpress.stackexchange.com/”,get_template_directory()); $i = 0; // loop included files foreach ($includedfiles as $includedfile) … Read more

When a link doesn’t exist, how to tell WordPress what to do? (404 Error Page)

The conditional you use to output get_template_part(‘content’, ‘none’); is only triggered if there is no post in the main loop, for example, when a category has no posts in it: if (have_posts()){ while(have_posts()) { the_post(); // If the category has a post and we are on a category page, then show the posts get_template_part(‘content’, ‘archive’); … Read more

For custom templates, is it better to use `template_include` or `type_template`?

{type}_template is a filter inside the get_query_template function. That function is called by a series of functions called get_home_template, get_category_template and so on. It allows you to very specifically target templates. You can see it in action in template-loader.php, where the $tag_templates variable is defined, binding conditions like is_home, is_category and so on to the … Read more

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