Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

61

I could finally get rid of that using this: function my_deregister_scripts(){ wp_deregister_script( 'wp-embed' ); } add_action( 'wp_footer', 'my_deregister_scripts' );


28

Actually all styles should be placed in header. So WordPress doesn't have a parameter for doing this in the wp_enqueue_style function, because traditionally all styles were added in the head. Recently, many sites have moved to a system where critical "above the fold" styles are loaded in the head, while other styles are loaded in the footer. So here is a ...


22

This will do the trick when added to your functions file: if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null); wp_enqueue_script('jquery'); }


20

I arrived at this thread with the same question: What does the wp-embed.min.js file do? None of the current answers accurately address this question. Firstly, I am fairly certain that embed.min.js does not relate to embedding oEmbed content from other providers: Vimeo, YouTube etc. You can remove embed.min.js and those embeds will continue to function. It ...


19

Add this to your functions.php: function my_footer_shh() { remove_filter( 'update_footer', 'core_update_footer' ); } add_action( 'admin_menu', 'my_footer_shh' ); or, if you'd like to hide it from everyone except admins: function my_footer_shh() { if ( ! current_user_can('manage_options') ) { // 'update_core' may be more appropriate ...


14

You should always add javascript (and styles) with the Wordpress function wp_enqueue_script() Works like this: wp_enqueue_script( $handle // the name of your enqueued file, in your case 'myscript' ,$src // source of your file, can be external, or for your example: get_bloginfo('template_directory') . '/js/scripts.js' ,$deps // does your javascript ...


11

Looking at wp-includes/template-loader.php … there seems to be a way: if ( $template = apply_filters( 'template_include', $template ) ) include( $template ); You could hook into that filter, handle the including in a callback function and return FALSE. Sample code, not tested: add_filter( 'template_include', function( $template ) { get_header(); ...


8

If you're just using a small script or other markup, you can hook a function to the wp_footer filter, which should be included in all properly-coded themes: add_action( 'wp_footer', function () { ?> <script language="javascript" type="text/javascript"> startcart() </script> <?php } ); However, if your JavaScript code is more ...


8

Trix's answer didn't work out for me on WordPress 4.4.1, but I found a solution in the code of Disable Embeds WordPress plugin. Add this code (modified) in your theme's functions.php file to remove the wp-embed.min.js file from the frontend completely: add_action( 'init', function() { // Remove the REST API endpoint. remove_action('rest_api_init', '...


7

This works for me: <?php /** Plugin Name: Admin Footer Text Remover **/ add_filter( 'admin_footer_text', '__return_empty_string', 11 ); add_filter( 'update_footer', '__return_empty_string', 11 ); where I use the __return_empty_string function as a callback.


7

In a WordPress footer hooks are different for back-end(dashboard) and front-end. In Dashboard use "admin_footer" hook. In Front-end use "wp_footer" hook.


7

A quick search shows this question has been asked and answered many times. From StackOverflow: Make footer stick to bottom of page correctly From StackOverflow: How to get the footer to stick to the bottom of your web page. From CSS-Tricks: 5 different ways to make a sticky footer From Code Pen: "Always on the bottom" Footer From WordPress: How to make ...


6

There are 3 methods. Somewhat weird but since this text is internationalized you can filter the output. This is just an example to remove the text, the link is still present in the source. add_filter('gettext', 'remove_powered_by', 20, 3); function remove_powered_by( $translated_text, $untranslated_text, $domain ) { $custom_field_text = 'Proudly ...


6

You have true set in the 4th parameter (version), not the 5th. wp_enqueue_script( 'my_javascript_file', //slug get_template_directory_uri() . '/javascripts/app.js', //path array('jquery'), //dependencies false, //version ...


6

That's an old question, here is another and easy solution for WORDPRESS MULTISITE MENU sharing across all network sites, Not only menu you can use the same method to share anything other then widgets across all the network sites. here is the solution : Edit your Header.php //store the current blog_id - Use this function at the start of the function that ...


5

If you change the priority on the hook to wp_footer you should be able to shift when it's called in reference to the enqueue functions. Example: add_action('wp_footer', 'my_footer_hook', PHP_INT_MAX);


5

This is what ended up working for me: Put your script into a .js file and then: add_action( 'login_enqueue_scripts', 'enqueue_my_script' ); function enqueue_my_script( $page ) { wp_enqueue_script( 'my-script', 'http://domain.com/path/myjs-file.js', null, null, true ); }


4

I am not sure if you posted code as-is or extracted part of it, but per this snippet - you are hooking function inside itself. Which doesn't seem like it will work nicely. :) Also init hook should not be used for enqueue, on front-end hook to use is wp_enqueue_scripts, see where is the right place to register/enqueue scripts & styles. Example functions....


4

Hook into 'admin_footer-post-new.php' and 'admin_footer-post.php', check the global variable $post_type: add_action( 'admin_footer-post-new.php', 'wpse_73692_script' ); add_action( 'admin_footer-post.php', 'wpse_73692_script' ); function wpse_73692_script() { if ( 'post' !== $GLOBALS['post_type'] ) return; ?> <script>alert( '<?...


4

The other answer is not working for my site. I tried this script instead and it works fine for removing the WordPress version number from the right footer of admin pages: add_filter( 'admin_footer_text', '__return_empty_string', 11 ); add_filter( 'update_footer', '__return_empty_string', 11 );


4

Look in the parent theme's functions.js. It looks like an implementation of the "sticky footer" concept. The margin is being set via script: var body = $( 'body' ), _window = $( window ); /** * Adds a top margin to the footer if the sidebar widget area is higher * than the rest of the page, to help the footer always visually clear * the sidebar. ...


4

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 ...


4

I think this part is still missing. What does the wp-embed.min.js file do? I noticed it is added to the end of my blog page footer. The answer to this question is in the track. https://core.trac.wordpress.org/changeset/35708 Embeds: Remove & characters from the inline embed JS. Older versions of WordPress will convert those & characters ...


4

The quick and dirty way would be to either delete the two lines that are 'resposible' for the message, or wrap them by comments / comment-them-out. In your theme folder 'twentysixteen' look for the theme file 'footer.php' Around line 50 look for the following two lines: <span class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?&...


4

The best solution to customize a theme is to create a child theme. You can then copy the file footer.php from parent theme to child and edit it by removing the lines that outputs "{site} / Proudly powered by WordPress". That way you will be sure that any changes made will remain even after updating the parent theme.


3

This is not an error, it is a warning. You can make this go away by: Fixing the warning Write errors to the error log instead of the screen ( best practice ) To fix the error, I recommend looking at what's hooking into wp_footer etc, or using a PHP debugger


3

I don't think there's anything fundamentally wrong with your approach, I see it pretty often. You could hook parse_request and 301 redirect any requests to footer to the front page. I wonder though how visitors would end up there in the first place, as long as you exclude it from the sitemap and don't link to it anywhere. Or you could create a custom post ...


3

First a bit of advise (since the solution is based on it) - always "enqueue" your scripts, don't just add them in the footer. Read this, for example . Now the solution for loading scripts on specific template, since this is what you asked for: function enqueue_themescrits() { if ( is_page_template('contact.php') ) { //the file your contact page uses ...


3

Have you perhaps copied in the admin bar links into the footer.php file by accident? At the bottom of footer.php you should see a function call "wp_footer();".


3

If I interpret the question correctly you: Don't have any .js javascript files Output any javascript you have from an .php file (presumably code) Include this javascript on the bottom of the page by including the .php file. So you are actually doing: Correct Combining all the javascript in one file Having the javascript in the footer Minimized the number ...


Only top voted, non community-wiki answers of a minimum length are eligible