new to javascript – using in instead of functions.php, not loading correctly

Start by putting your JS in an appropriate .js file in your theme directory. Use the wp_enqueue_scripts hook (this is where you will enqueue/load any of your custom javascripts). Within that hook, use wp_enqueue_script() to load your script(s). Example: add_action( ‘wp_enqueue_scripts’, ‘enqueue_my_stuff’ ); function enqueue_my_stuff () { wp_enqueue_script(‘slug_for_your_script’ , get_template_directory_uri() . ‘/path/to/yourscripts.js’, array(‘jquery’) ); }

Add OG meta tags to wp head

Well You can also try by adding action inside. function after_submission( $entry, $form ) { $name = $entry[2]; $item = $entry[5]; insert_og_in_head( $name, $item ); add_action( “wp_head”, “insert_og_in_head” ); } add_action( “gform_after_submission”, “after_submission”, 10, 2 ); function insert_og_in_head( $name = NULL, $item = NULL) { global $post; if ( !is_page( 6 ) ) //if it … Read more

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

hook into init action on your initial plugin function add_action(‘init’, array(__CLASS__, ‘your_function_within_class’)); and add the function public static function your_function_within_class() { wp_register_style(‘myfirstplugin-admin-css’, ‘/wp-content/plugins/myfirstplugin/assets/style.css’, false); wp_enqueue_style(‘myfirstplugin-admin-css’); } hope this help

Post Attachment missing head (stylesheets/js/what-not)

A good place to start is with the template hierarchy flow chart. http://codex.wordpress.org/images/1/18/Template_Hierarchy.png I’m always consulting this page. When you say modified twenty eleven, what do you mean? The image.php file is what handles image attachment pages in twenty eleven. I’m not familiar entirely with how it works, but it may be also making a … Read more

Background of default template showing instead of the background of custom page template

As I suspected, the issue is where/how you’re outputting your custom stylesheet. First, move this to functions.php: function mypage_head() { echo ‘<link rel=”stylesheet” type=”text/css” href=”‘.get_bloginfo(‘template_directory’).’/OldSkool-src/style.css”>’.”\n”; } add_action(‘wp_head’, ‘mypage_head’); Second, change the action into which you’re hooking your callback. You’re using wp_head. All other stylesheets will be using wp_print_styles. The wp_print_styles action fires inside of the … Read more

output specific location in the header

Okay, here is a working example of what you (might) want to do. Put the following in your functions.php: add_action(‘wp_head’, ‘my_jquery_code’, 999999999); function my_jquery_code() { $jquery_code = <<<JQUERY <script> // jQuery code goes here… </script> JQUERY; echo $jquery_code.PHP_EOL; } // function my_jquery_code