Questions tagged [wp-head]

Uses do_action() Calls 'wp_head' hook.

Filter by
Sorted by
Tagged with
0
votes
2answers
609 views

Add inline style to pages where shortcode was used

I am trying to add a style to the header, using this method the style only loads on single posts but if I use a shortcode to load the post content that style does not load in the header: add_action( ...
0
votes
3answers
4k views

Remove meta description on certain pages

Wordpress renders a meta description tag with the content of the blog post as the value for the description. I already generated in the header.php what I want the description to be, no matter what. ...
1
vote
0answers
281 views

wp_head function not outputting

I've been trying to figure out what I could possibly be doing wrong with this plugin I just coded, from what I see, everything should be working correctly. However, it's not doing anything at all. No ...
1
vote
1answer
873 views

Removing Visual Composer head meta (works alone but not with IF)

I'm trying to remove the head meta added by VC, namely "meta name="generator" content="Powered by Visual Composer - drag and drop page builder for WordPress". If I add: add_action('init', '...
0
votes
1answer
36 views

Calling JavaScript for specific page irrespective of whichever theme you select

I recently added a JavaScript file that pulls JSON data and updates the div tag on specific page of my WordPress, now to apply the JavaScript file to the page I added to header tag in the theme and ...
2
votes
1answer
944 views

How can I get wp_head() as a string instead of echoing it?

I'm using PHP handlebars templates and would like to keep all of the HTML in the template file so I don't have a header.php but rather the handlebars looks like <html> <head> {{#...
2
votes
2answers
151 views

Track down where script is being enqueued from

I have a WordPress site with an SSL certificate. It all works fine, except that this little insecure shield icon shows up because the header has an enqueued non-https script. The issue is that I ...
0
votes
1answer
1k views

Auto Generated HTML source code formatting

I've had this question for a long time and I was wondering if anyone had an answer for it. I know its not really important, but for someone like me who really likes very clean markup things like this ...
0
votes
3answers
9k views

Remove all theme CSS & JS from wp_head (but only for 1 page template)

I have a page template, which is working nicely. But when I include , it loads the themes CSS and js files, which breaks my page template. However, I still need the wp_head for some plugins to work. ...
2
votes
1answer
15k views

How can i remove JUST the title tag from wp_head() function?

i'm using wordpress 4.6 i'd like to remove just the title tag automatically outputted by wordpress because need to hardcode the html title tag in the template. i guess is something like this: ...
0
votes
1answer
192 views

Adding code to head to all pages manually

I've been googling for days and I didn't find a solution. I need to add a JS code to the head of all my pages, and I wanna do that manually (without a plugin). I found a '~/wp-content/themes//header....
0
votes
2answers
956 views

Include HTML (Bootstrap Modal Box) with a plugin into my header

I want to include some HTML, spezific a bootstrap modal box. This is my function with the HTML part: public function dmd_fav_modal_box() { $content = '<div class="modal fade" id="...
2
votes
3answers
4k views

Modify page title format (when using title-tag)

Currently my page titles are handled by WordPress, in a call to wp_head (I have add_theme_support( 'title-tag' ) in functions.php). I'd like to change the page title format for category archives - ...
1
vote
1answer
56 views

What is the safe way to print tracking code / pixel code before </head> tag or </body> tag

What is the safe way to print tracking code / pixel code before </head> tag or </body> tag from theme options. In header.php I printed the following code before the </head> tag if (...
3
votes
2answers
12k views

Remove rel='dns-prefetch' href='//maps.google.com' from wp-head

How to remove this from WP head: <link rel='dns-prefetch' href='//maps.google.com'> I had this also: <link rel='dns-prefetch' href='//s.w.org'> But, I removed it with this code inside ...
2
votes
2answers
2k views

How to add inline css/js inside a shortcode

I'm working on creating a shortcode which is meant to change the css and js dynamically for that shortcode based on the situation. Now the problem is that I not getting a clue about how to use ...
0
votes
1answer
642 views

How to remove page title from wp head on specific page?

I'm trying to remove page title from a template. Actually I'm using custom in title for singledigital.php template, and wp_head also adding page title on this page. So i want to remove it. I have ...
0
votes
1answer
868 views

Custom field as meta description

I want to make a description input field inside the normal post adding page (in the dashboard) so each time I'm posting something I'll be able to handle the description as I like. Then I would target ...
0
votes
1answer
377 views

Output dynamic_sidebar_params in wp_head

I have created a custom widget with a color picker field. Currently there are two ways to output the color picker value for this widget: Inline style. Using the dynamic_sidebar_params filter. With ...
0
votes
1answer
5k views

Cannot retieve the_content() and the_author() - both returning empty strings

I am creating the following code to display open graph meta data in the header of my single.php page add_action('wp_head', 'mycode_add_og_meta_tags', 5); function mycode_add_og_meta_tags () { ?> ...
3
votes
2answers
161 views

Display custom_background outside wp_head()

My theme is a very small one page theme which really doesn't need all the scripts, so I've created a few options to remove wp_head() and wp_footer() so the user can choose if they want to enable or ...
2
votes
1answer
3k views

Change Page's <title> Tag Using functions.php File

In my child theme's functions.php file, I'm trying to change a page's title tag: function custom_title() { return "Page Title"; } add_filter( 'wp_head', 'custom_title', 9999 ); The code above is ...
0
votes
1answer
206 views

How to hook into <head></head> container

I want to add my own <meta /> tag inside the <head></head> container on every page or post within the loop(). Is that possible? What hook(s) should I use for that?
4
votes
3answers
7k views

Is there a way to read or list wp_head() contents?

I am working on a CSS and JS compiler and need to find a way to list the contents of wp_head() I am trying to get a list of all CSS/JS files and inline CSS on any give page. Hooking on the wp_head ...
0
votes
2answers
2k views

Custom script file enqueue has “?ver=4.5.1” when loading and doesn't update

I'm loading a custom script file using an enqueue and here's the output: <script type='text/javascript' src='.../wp-content/themes/enfold-child/js/custom_script.js?ver=4.5.1'></script> ...
0
votes
2answers
484 views

How to get a single hook from wp_head()?

I am working on a custom post type and I don't want it to get all the clutter from wp_head(). However, I do want to show a specific hook, for example the YoastSEO meta tags. How do I call a specific ...
0
votes
1answer
77 views

How to check widget-cpt meta and display its custom css in the head?

When dealing with a widget that is a custom post type, is there a way to detect when that widget is displayed, then check its post meta for any custom css and enqueue it in the head of the site? ...
2
votes
1answer
3k views

Putting content into header.php without using wp_head

I am building a plugin. I have to output certain stuff in the header.php file of the theme depending on if/else I will write. However I am not at that point yet. I just learned in order to push the ...
0
votes
1answer
2k views

How to output wp_enqueue_style() in HTML head instead of footer

I added some actions to wp_enqueue_scripts to load my custom css and js files in the header section by using wp_head(); right before the closing </head> tag. function mytheme_scripts(){ // ...
2
votes
3answers
4k views

How to control initial wp_head() output?

I followed the common advise to use wp_head() in header.php and wp_enqueue_scripts() instead of hard linking css and js files in header.php. However, I realized that wp_head() outputs lots of stuff I'...
0
votes
1answer
53 views

Grab ID from post from plugin and use it to create an object

I want to create an object and set ID for this object like $p = new Product(87); I have this code within a plugin and I want to grab the ID of the custom post being showed: function getPostId(){ ...
2
votes
1answer
3k views

Remove specific CSS and JS from the head

I'm trying to remove some specific lines from the WP_HEAD. Now my header looks following way: <link rel='stylesheet' id='bootstrap-css' href='/themes/wp-e/css/bootstrap.css?ver=4.2.2' type='text/...
7
votes
3answers
1k views

Any advantage of using wp_scripts and is_IE when enqueuing scripts

I read on the WP docs, which pointed to this gist that the correct way to enqueue styles for IE is by using the $wp_styles. I'm guessing that this would be true then for scripts as well. Take these ...
0
votes
1answer
696 views

custom COOKIE on custom page

i have problem with create function for set cookie dynamically. when i try in custom page i have of course header is set and i tried something like this: in custompage.php: myfunction($cookiename,$...
1
vote
1answer
47 views

Get latest posts from WordPress site without header, menu and sidebar

I have no knowledge about WordPress. However, I want to fetch and display the latest posts of a WordPress site in an application window. One way to do so is to use the RSS feed. However, this ...
1
vote
2answers
2k views

action hook wp_head higher priority as all other plugins/hooks

I work a bit with the wordpress API and I want to try to include a <meta>-tag into my head area of my website. This is my code (works everything fine!): class dmd_noindex_options_page{ ...
0
votes
0answers
171 views

Put dynamic Javascript in header after doing operations

I want to write a plugin that enables a function to be put in my theme in various places. Then I would like to collect the parameters called and generate a Javascript and put it into my site <head&...
0
votes
4answers
4k views

ACF custom field in <head> [closed]

I've created an image field using Image URL via the ACF plugin. This field appears across my pages. This field enables admin to change the background image for a selected class. Here's the code I ...
0
votes
2answers
6k views

using wp_head in body tag for css style

I am trying to add css code into head tag. the css style is from shortcodes. title text from shortcode and title color / font size.. etc. This is an example. <html> <head> <?php ...
0
votes
2answers
1k views

add_action to wp_head is added, but not called

I'm using the CiviCRM plugin for WordPress, and in the plugin's main file, civicrm.php, it calls add_action() to add a function to wp_head() in order to merge CiviCRM's header with my theme's header: ...
5
votes
1answer
4k views

wp_head() gives me some weird CSS

I was trying to enqueue my stylesheets but it didn't work. Turns out I had forgotten to include wp_head() inside my <head> tag. So I did and then my stylesheets where loading fine. The problem ...
0
votes
1answer
499 views

How to style injected code in header section?

Trying to add custom code to header section <head>..</head>of the blog by adding this code to child-theme functions.php // Add scripts to wp_head() function child_theme_head_script() { ...
0
votes
2answers
106 views

Best use adding user generated JS/CSS to a theme with a plugin

I want to know the best use of adding custom JS/CSS to a theme. I have built a small plugin which has a section to allow users to add CSS/JS to their theme. Now I am trying to figure out is which is ...
3
votes
1answer
11k views

Change title in head on Archive page

I'm having problems with figuring out how I can change the title on my archives pages. I now have a title like this: <title>Jobs Archive - The Company</title> But I would like to have a ...
0
votes
2answers
1k views

Remove tags from wordpress head

I don't know when or why but this tags are inserted on my wordpress head automatically and they are adding style that disturb my layout: <meta name="generator" content="WordPress 4.2.2"> <...
1
vote
1answer
44 views

How can I add Javascript in the header of all post pages and only post pages

I am using add_action('wp_head', 'function_that_returns_js_string') in functions.php but it is adding the string in the header across the site. How can this be narrowed down to be only included in ...
8
votes
1answer
856 views

How can i get the name parameter defined in get_header?

For example, on my blog pages i use get_header('blog');, but i don't want to create a new header template called header-blog.php, because i just want to make a small adjustments. Is it possible to ...
1
vote
1answer
76 views

How to replace a function using a child theme?

I have the following function where I would like to replace the image nopic.jpg I have updated by deleting some redundant options. if ( ! function_exists( 'TaskerDev_get_first_post_image_fnc' ) )...
3
votes
1answer
924 views

Wp_head and wp_footer vs wp_enqueue_script javascript files?

I'm converting a bootstrap html website into Wordpress. Now, all recommend using wp_enqueue_script() for registering javascript files. i.e. function themeslug_enqueue_script() { ...
0
votes
1answer
1k views

Adding javascript to functions.php causes problems with my template

I want a "Read on" link that moves to another part of the page when clicked. I understand the HTML bit and I have even used some nice scrolling. It works. But when implemented breaks part of my ...