Calling an image within the theme folder from inside a post/page?

I realize that this was posted about 7 months ago, but in case you’re still looking for a solution to this, add this to your functions.php file: /** * Add a shortcode for the current theme directory * @return string Current theme directory */ function yourtheme_get_theme_directory_uri() { return get_template_directory_uri(); } add_shortcode( ‘themeuri’, ‘yourtheme_get_theme_directory_uri’ ); Then … Read more

Change location of header.php and footer.php

It is not possible to override header/footer via hooks in respective get_header()/get_header() functions. However it is often overlooked that these function allow input and loading different headers. For example get_header( ‘nested/header’ ); will look for header-nested/header.php in theme’s folder. It’s kind of a hack in regards to subdirectory use, but it works. 🙂

Is it safe to include a javascript file in a template’s php file?

As @N00b mentioned Yes, it is safe adding a JS script as long as it doesn’t include any sensitive information. JS is fully exposed to client, you shouldn’t do it anyway. But your situtaion it is better to create a site specific custom plugin and add JS using it. Example : function themeslug_enqueue_style() { wp_enqueue_style( … Read more

Different template for posts of all subcategories of category

You can check if current category is a child of blog category with cat_is_ancestor_of() function or term_is_ancestor_of(), or maybe better, use in_category(), as you are currently doing, but checking child categories as well. add_filter( ‘single_template’, ‘get_custom_cat_template’ ) ; function get_custom_cat_template( $single_template ) { // You want to filter only template for single posts of default … Read more

ACF – Theming Flexible Content

And to add to previous answers, you can not only use get_template_part, but also use it’s second param and combine it with ACFs get_row_layout. So let’s say that somewhere in your template is: <?php while ( have_posts() ) : the_post(); ?> <article> … SOME CODE <?php while ( have_rows( ‘YOUR_FIELD_NAME’ ) ) : the_row(); ?> … Read more

Custom page for WooCommerce’s /product-category/

product-category URL uses taxonomy-product-cat.php which calls archive-product.php you will need to override it by creating the same file with the same name in themefolder/woocommerce/archive-product.php You can open any file in templates folder in the WooCommerce plugin and you will find a line in the very top comment describes how to override the file. Don’t forget … Read more

Merge multiple custom post types in a single archive template

As Jacob Peattle mentioned, you should not be using query_posts in your custom archive templates, that’s redundant as WP is already going to query those posts for you. What you really need is pre_get_posts (https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). That will allow you to conditionally modify the parameters of the main query before it executes. Additionally since you are … Read more

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