Wordpress header template not updating code - php

I'm working on a Wordpress theme locally. At some point all of the sudden changes to my header.php template stopped showing up on the site. A change in any other file is visible. I believe this started happening after I played around with Appeareance->Menu.
What I've done so far:
Made sure it's the right file, right path - yes
Cleared browser cache
added define( 'WP_CACHE', false ); in wp-config.php
erased all the code in the header.php file - no change, website looks normal so I undo the erase
removed get_header() from page.php - the website got ugly, put it back on - the website looks ok but still no changes visible from header.php (I have a huge <h1>blah blah</h1> in there)
rolled back a few commits back - still nothing
switched to another theme and then back to my theme - still no changes to header.php
performed rm -rf on wp-content/cache/* - still nothing
checked my theme on a different WordPress install - MY CHANGE IS VISIBLE, but I want it where it was so far so that doesn't solve my issue but it does seem to be some cache issue after all if it shows up in another install.
What else can I do? I've been out of ideas for a few days now.

I finally figured it out (actually my programming duck did). It was a plugin (Elementskit Light) causing this strange behaviour.

You might've activated the Header from ElementsKit. (https://i.imgur.com/LC2RRVu.png)
You can simply turn off the Header. (https://i.imgur.com/n8Uzxkn.png)
But if you like to keep it activated and also need some additional custom code. Then ElementsKit also provides some hooks you can use.
These hooks are:
// Before Header
do_action( 'elementskit/template/before_header' );
// After Header
do_action( 'elementskit/template/after_header' );
// Before Footer
do_action( 'elementskit/template/before_footer' );
// After Footer
do_action( 'elementskit/template/after_footer' );

Related

Woocommerce not loading assets (JS/CSS)

Woocommerce is not loading my assets. I can see all my other theme assets files like css, js and all that works perfectly. I have my header and footer in place on the checkout page, in my header.php I got my <?php wp_head(); ?> in place and that seems to work alright except for Woocommerce.
Currently my checkout is loading purely the html without any assets. JS wont work (eg. clicking to toggle coupons field), css wont load.
How may I solve this? tried to override the form-checkout.php (https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/checkout/form-checkout.php) and force my get_header and get_footer, without any success.
maybe try to find if for some reason your theme is disabling it?
look for code like this - add_filter( 'woocommerce_enqueue_styles', '__return_false' ); OR define( 'WOOCOMMERCE_USE_CSS', false );

Can't find where the do_action("This function") leads to in wordpress theme

I have this in my index.php file. It adds the home banner image in WordPress. I know that it is mostly generated in WordPress customizer, but I need to add an anchor tag in this section. I can't find it anywhere in the file structure.
<?php do_action('cleanblog_index_top'); ?>
I'm not able to find where cleanblog_index_top leads to. Any help would be great. Thank you!
I stumbled on this old one while looking up the docs for do_action(). The answers are brutal so I decided to provide a better answer in case anyone else stumbles here.
If a WordPress theme has something like do_action( 'example_action_hook_tag' ) somewhere in one of the template files (such as index.php, page.php or whatever) the purpose is to provide theme or plugin authors with a way to write their own custom function that they can then "hook" onto the action with the function add_action().
WordPress would then call this function any time and anywhere do_action( 'example_action_hook_tag' ) is called.
The creators of commercial themes will often litter their template files with hooks declared with do_action() to make it easier for their customers to customize their themes via functions.php or by writing a site-specific plugin.
It looks to me that this is the likely scenario that is impacting the OP. This also explains why the OP was unsuccessful in finding where this "leads to".
It would only "lead somewhere" if the OP wrote a function in the theme/child-theme functions.php or in a plugin and added the line do_action( 'cleanblog_index_top', 'name_of_ops_function' ) to hook their function onto the cleanblog_index_top. WordPress would then call their function when do_action( 'cleanblog_index_top' ) was called in index.php.
From the name of the OP's hook, cleanblog_index_top, it sounds like the theme author intended to provide a way for others to inject output at the top of the index page template.
Suppose the OP wanted <h1>Hello World</h1> to appear there.
In functions.php of a theme/child-theme the OP could add a function that echo's this out:
function op_customization() {
echo '<h1>Hello World</h1>';
}
And hook their function onto cleanblog_index_top:
add_action( 'cleanblog_index_top', 'op_customization' );
Cheers!
You should never edit the index.php file directly, for the same reason you should never edit core Wordpress files directly - the next time WP pushes an update, your changes will be overwritten (and that assumes you don't break anything). Never edit plugin files directly, same reason.
You need to look in your theme, you should only make changes to the functions.php and style.css files in your theme - unless you create a child theme and that is a topic you should Google.

How to trace which function in Wordpress adds certain code to header?

I want to remove most css and scripts added to my Wordpress by plugins and maybe core Wordpress. How can I trace which function adds which line in my page header?
Tried to run search for the lines I want to remove but unsuccessfully. I know already that the code is done through wp_header hook but it does not help finding exact function.
If you know which plugins add the code you can go through plugin files in wp-content/plugins/plugin-name and find following functions.
wp_enqueue_script()
wp_enqueue_style()
Usually it will be together and wrapped in another function which will be called by action:
add_action( 'wp_enqueue_scripts', 'name_of_function' );
For not loading the scripts just uncomment add_action line.
But please be aware, that those scripts are usually vital for correct function of plugin so you will have to serve them from somewhere else.
Also when disabling wp_enqueue be sure you are not disabling admin scripts which would be loaded by action
add_action( 'admin_enqueue_scripts', 'name_of_function' );
To be sure always check parametres of wp_enqueue function where script name should match the script you had previously seen in head section of your site.
Every update of plugin will override the files and therefore enable scripts again
Hope this helps.

wordpress theme twentysixteen page content not Display

I am using Wordpress twenty sixteen theme in my project, but page content, not displaying on front site in WP-admin adds page and puts content and update my front site display code is now:
<?php while ( have_posts() ) : the_post(); get_template_part( 'content', 'page' ); ?><?php //comments_template( '', true ); ?><?php endwhile; ?>
Content not showing up can be due to a few issues, but without access to your site, it's nearly impossible to be sure.
Here are a few things to try:
Disable all plugins to make sure none of them are interfering with your site. If your site reappear, Deena Le them one by one to see which one is causing the problems.
Reset permalink in setting to "plain" to see whether you've configured your site properly
Your PHP version may be too low (upgrade) or the pcre.backtrack_limit is set to 100000. In order to check, create a phpinfo.php file with this
code:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
And then navigate to it in your browser.
If it's low, create a php.ini file or edit the existing one and modify or add the line pcre.backtrack_limit=1000000
Check in setting->reading you're showing your latest posts (and make sure you have at least one post published (not draft). If that is the problem, and you want to show a static page, you may have a problem with the static page.
Make sure you have the latest version of Wordpress installed.
Rename your theme folder in FTP from twentysixteen to twentysixteen-temp to make sure it's not the theme.

Why my template directory being spit out from wp_head?

I have a site in development that seems to be spitting out my template directory from wp_head. It's driving me crazy.
I inherited this site and I'm trying to make it work. I don't know what I should be looking for in the files.
here's the site in question: http://discoverthebody.ca/test/
Can anyone help with what I should look for?
EDIT: To clarify, in my header.php, I've narrowed down the error to happening here:
<!-- wordpress head functions -->
<?php wp_head(); ?>
<!-- end of wordpress head -->
The stray template directory call is being output right after that comment, so I assume wp_head() is where it's happening.
I'm not entirely sure what is it. I happened to notice that you have the plugin woo e-commerce enabled. I've noticed that plugin has really gone downhill lately, and tends to do a bunch of random stuff as well as not even work. Try disabling that plugin and seeing if it helps.
If it doesn't, try disabling your plugins one-by-one. If that doesn't fix it, look in header.php in your theme directory. for a stray link in the HTML.
if I was in your shoes I would do a site-wide search (ie grep) for one of these:
bloginfo( 'template_directory );
bloginfo( 'stylesheet_directory' );
get_stylesheet_directory_uri()
get_template_directory_uri()
TEMPLATEPATH
see: http://codex.wordpress.org/Function_Reference/bloginfo

Categories