I have done a lot of search on it, most of the people are saying
wp_head() is located in wp-includes/general-template.php
wp_head is in default-filter.php in wp-includes
But I want to know where the html/php file placed in file directory that is rendered by wp_head(), so I can edit that file. Thanks
The wp_head() function simply calls all functions hooked to the wp_head action. Various functions will be hooked to this action, they may reside in the WordPress core, or perhaps in plugins you may be using, or even in your theme's functions.php file.
To my knowledge, there isn't a specific wp_head template 'file' that you can edit.
Ref:
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
http://codex.wordpress.org/Function_Reference/wp_head
Following https://codex.wordpress.org/Function_Reference/wp_head
wp_head() is located in wp-includes/general-template.php.
If you want edit something, execute a Control+MAJ+F (Find in folder) in wp-includes and it gives you the file where the specific content should be edited.
wp_head() is located in wp-includes/general-template.php.
Related
I am starting to study Wordpress a bit deeper and i d like to know which way functions.php file is loaded so that every function is available everywhere in the theme files.
Or at least if you suggest me some source where to find this information.
Thank you
A function.php file:
Executes only when in the currently activated theme's directory.
Applies only to that theme. If the Theme is changed, the functionality is unused.
Requires no unique Header text.
Is stored with each Theme in the Theme's subdirectory in wp-content/themes.
Each theme has its own functions file, but only the functions.php in the active Theme affects how your site publicly displays. If your theme already has a functions file, you can add code to it. If not, you can create a plain-text file named functions.php to add to your theme's directory.
Source # https://codex.wordpress.org/Functions_File_Explained.
In short, the function.php file is a function wrapper. Each function is hooked to a specific action hook. These actions are called when a user opens a page (Server request).
You can get a better understanding of how action hook work by looking at the Plugin API/Action Reference which represent a typical hook firing sequence.
As the title says, I want to add some sort of signature with comments on my wordpress index file, thing is - there are 30 different index files and none of them seems to work
If I understand correctly, it'll just be a case of adding some HTML comments (not PHP comments as they won't show in the source code) in your theme files. Bear in mind that editing a theme won't work if someone else made it and releases updates to it as it'll overwrite your changes if you update it.
The best place to add in the comments is to either open the header.php file and place your HTML comments after the opening <body> tag. If your theme doesn't include a header file, you could always add your comments to the top of your themes index.php file instead.
Your theme should be located within /wp-content/themes/YOUR-THEME/.
Alternatively, you could also place HTML comments between the <head> tags of your theme so they show up a bit higher in the source code. To do this, it's probably best to use an action hook instead. Place this in your themes functions.php file:
add_action( 'wp_head', 'add_signature_to_theme', 1, 0 );
function add_signature_to_theme() {
?><!-- Welcome to my website. --><?php
}
The wp_head action hook documentation is useful to have as reference as well if you'd like a bit more information on what it is and what it does.
I am new to WordPress. I was referring to code of WordPress theme. I am confused about where to put our function and add_action() for that function.
I want to know whether it is right to define function and add_action in one PHP file and put it anywhere in our theme folder.
"functions.php" is the file where you want to put your custom functions, hooks and actions. If your theme doesn't have a functions.php just create it. Wordpress will get the contents of it automatically, so you will have access to defined functions anywhere in your theme.
I want to insert a hardcoded short code in my code, and not from the usual Text Editor we usually use.
Basically I want this to add a gallery, and the user doesn't need to change the shortcode from the CMS so I will be hardcoding this.
How would I need to do this, I tried to just post it in my .php file but it doesn't work.
This is the code I want to add:
[jj-ngg-jquery-slider gallery="1" width="866" height="341" ]
This will do the trick to include in .php files:
<?php echo do_shortcode('[jj-ngg-jquery-slider gallery="1" width="866" height="341"]'); ?>
shortcodes were created to include in post or pages. I could be wrong but wordpress checks the input of a post and if it finds a shortcode it will replace it with the html. I don't think it will work if you add shortcodes in your .php file because wordpress doesn't look for shortcodes in your php files
You could just create a function in functions.php to generate the html you need. Then you just call that function within your theme .php file. That's how most plugins are made. Shortcode for post & pages and function in the php files.
example:
<?php echo myGallery(array('gallery'=>1, 'width'=>866, 'height' => 341); ?>
Did you try this method ? do_shortcode($content)
I've seen it on http://codex.wordpress.org/Shortcode_API
Using wordpress 2.9.2. I am loading my css files for plugins as they are being called, which ofcourse is after my header has been loaded. I want to insert the calls those css files in the HEAD tag of the page, which can be done if i get a hook which includes lines in the head after wp_head() has been called. Help !
Look at http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head - the action is called wp_head.
You will want to use wp_register_style() to register your CSS file followed by wp_enqueue_style() to actually add it to the list of stylesheets that are output.
There is an example on that page, but replace 'wp_print_styles' in the example with 'wp_head'.
Have you tried echoing the styles or .css include the in a function passed into wp_print_styles API action hook?
If you are using your own theme, you can just put <style> tags in your header.php file pointing to the stylesheets you are using.
If you need a hook, it is called wp_head (check the Codex documentation on it).
The solution that worked for me was inserting the css files in head using output buffer.