Hide pages from google and visitors

Add a simple checkbox to the post editor to toggle the generation of a meta field that disallows search engines to index your content. Then hook into wp_head, check for the setting and print that field. Sample code for a plugin: add_action( ‘post_submitbox_misc_actions’, ‘show_noindex_checkbox’ ); add_action( ‘save_post’, ‘save_noindex’, 10, 2 ); add_action( ‘wp_head’, ‘insert_noindex_meta’ ); … Read more

wp_enqueue_script won’t load in header?

Write wp_enqueue_script in wp_enqueue_scripts action function load_kenburns() { if ( !is_admin() ) { wp_register_script( ‘kenburns’, get_template_directory_uri() . ‘/js/bannerscollection_kenburns.js’, ”, ”, false); wp_register_script( ‘jquery-ui’, get_template_directory_uri() . ‘/js/jquery-ui-1.8.16.custom.min.js’, ”, ”, false); wp_register_script( ‘jquery-touch’, get_template_directory_uri() . ‘/js/jquery.ui.touch-punch.min.js’, ”, ”, false); wp_register_script( ‘kbsettings’, get_template_directory_uri() . ‘/js/kenburnsettings.js’, ”, ”, false); wp_enqueue_script( ‘kbsettings’ ); wp_enqueue_script( ‘kenburns’ ); wp_enqueue_script( ‘jquery-ui’ ); wp_enqueue_script( … Read more

This jQuery snippet doesn’t seem to work with WordPress

the problem was in your variable define syntax and also you need to wrap your jQuery script into no conflict wrapper, try this jQuery(window).load(function($) { // your function }); or (function($) { // your function })(jQuery); complete working script (function($) { $(window).load(function() { var lightBox = $(‘#lightbox’); var lightBoxContent = $(‘#lb-content’); var positionLightbox = function() … Read more

Ajax not firing properly using Firefox, but works in Chrome

This is the barebones for an AJAX call and response. Take a look and make sure this is working on Chrome and Firefox for you — works for me. <?php // Some function for data we’ll pass function dgx_donate_get_countries_requiring_postal_code() { return “cc postal code stuff…”; } // Register everything add_action(‘init’, function () { // Add … Read more

Including jQuery in WordPress

1) Only include scripts via wp_head(). For your custom script, register and enqueue it as such: function mytheme_custom_scripts() { if ( ! is_admin() ) { $scriptsrc = get_stylesheet_directory_uri() . ‘/js/’; wp_register_script( ‘mytheme_custom’, $scriptsrc . ‘custom.js’ ); wp_enqueue_script( ‘mytheme_custom’ ); } } add_action( ‘after_setup_theme’, ‘mytheme_custom_scripts’ ); 2) You need to deregister core jQuery, and then register … Read more

Stylizing external SVG files with jQuery and CSS

Sorry to say, but it’s not possible, because none of the elements from the SVG are read in the DOM, so CSS and Javascript don’t see them. All it sees is the <img> block, none of its contents. You have to import your SVGs into the page to have them be able to be manipulated. … Read more

adding the full image path to a wordpress javascript file

well first of all, don’t directly inject a script tag like that, use wp_enqueue_script to add your javascript file. additional data can then be passed from php to javascript via the wp_localize_script function. function wpa_scripts() { wp_enqueue_script( ‘wpa_script’, get_template_directory_uri() . ‘/js/script.js’, array(‘jquery’), null, true ); $script_data = array( ‘image_path’ => get_template_directory_uri() . ‘/images/’ ); wp_localize_script( … Read more

Bind to WPSetAsThumbnail

Yes, on your 2nd question 🙂 From what I saw in set-post-thumbnail.dev.js, it appears that you only need to add a link/anchor with the wp-post-thumbnail class on it in your quick edit screen. And you will get the image faded inside that link when the ajax request completes. For alerting “bacon” after the ajax completes, … Read more

How to include jquery validate in a template

Yes. You’re right. It’s because of the jQuery noConflict mode. You need to use jQuery instead of $. Or you can wrap everything in a function like this to define it’s scope (function($){ $(“#generateForm”).validate({ submitHandler: function(form) { $(form).ajaxSubmit(); }, rules: { … } }, messages: { … } } }); })(jQuery); Based on several posts, … Read more

AJAX post into pop-up div

Your code is not clear as it is out of context but it looks to me like you are loading your posts pages over AJAX through their normal URLs– URLs like http://example.com/this-is-a-post/ or http://example.com/2012/12/01/this-is-a-post/. The drawback to doing that you are loading the entire WordPress and theme framework into your popup, which may be much … Read more

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