AMP version of front page without plugin

is_single() will return false for Pages, so the above code as written should only work for single Posts. You’ll need to add more conditionals to your amp_page_template() function for each of the templates you want to replace with an AMP version. Depending on your settings in Settings > Reading > Front page displays, is_front_page() might … Read more

how to properly include or get file contents in a wordpress theme

There are 2 problems: include( get_template_directory() . ‘/audiounity/result.php’ ); The result of this is likely: /srv/www/example.com/public_html/wp-content/themes/audiounity/audiounity/result.php The first line of the Codex entry for that function is: Retrieves the absolute path to the directory of the current theme. If it’s a child theme, then you need to use get_stylesheet_directory. *_template_* functions always refer to the … Read more

How to use a template file to show all post having same metakey

You might give it a shot this way: add_filter( ‘template_include’, ‘check_post_meta_template_include’ ); function check_post_meta_template_include( $template ) { if ( !is_single() ) { return $template; } global $post; if ( $post->post_type != ‘post’ ) { // Proceed only if post type = post return $template; } $category_meta = get_post_meta( $post->ID, ‘Category’, true ); if ( $category_meta … Read more

Can I assign a Folder for Post Formats, without it affecting WordPress’ fallback/hierarchical system?

In general, “bad practice” is so common in the wordpress ecosystem, you will have to do something really bad for anyone to actually signal you out for doing it 😉 If you are the developer and maintainer of the theme, you should develop it in a way which will be easy for you to maintain … Read more

Index template always follows page_template() template?

template_include is a filter hook so you should use add_filter() instead of add_action(), it’s breaking the semantics here. Though both functions internally do the same thing. Try the following code, I haven’t tested it but it should work. Simplified and removed some codes. add_filter(‘template_include’, [$self, ‘load_route_template’]); public function load_route_template($template) { if (!$this->matched_route instanceof Route || … Read more

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