Passing variables to templates (alternatives to globalizing variables)
You could also use this function: set_query_var(‘foo’, $foo); WP will extract and expose all query variables in every template it loads, so you will be able to access it as $foo
You could also use this function: set_query_var(‘foo’, $foo); WP will extract and expose all query variables in every template it loads, so you will be able to access it as $foo
In your code example you have: wp_schedule_event( time(), ‘hourly’, ‘symbiocards_hourly_event’); but there is no symbiocards_hourly_event hook defined. If you are using it in the functions.php file in your current theme directory, then please try this snippet instead: add_action( ‘wp’, ‘symbiocards_activation’ ); add_action( ‘symbiocards_hourly_event’, ‘update_symbiocards’ ); function symbiocards_activation() { if ( !wp_next_scheduled( ‘symbiocards_hourly_event’ ) ) { … Read more
As of WordPress 4.6.0 there is a resource hints API that automatically adds all unique enqueued domains, which you can override with wp_resource_hints – you should only use the following answer if you’re stuck with < 4.6.0 All you can do is bump the priority of your hook: add_action( ‘wp_head’, ‘dns_prefetch’, 0 /* Highest priority … Read more
Normally WordPress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags. Add the following in your template file, it … Read more
There’s nothing wrong with enqueuing many files by using wp_enqueue_script. If you are referring to it as frustrating, then there is a simple solution for this. PHP offers a function that can list files and directories. By using glob you can list every .js file in your directory, and then enqueue them by a loop. … Read more
This function inserts your ad code after the specified paragraph. add_filter(‘the_content’, ‘wpse_ad_content’); function wpse_ad_content($content) { if (!is_single()) return $content; $paragraphAfter = 2; //Enter number of paragraphs to display ad after. $content = explode(“</p>”, $content); $new_content=””; for ($i = 0; $i < count($content); $i++) { if ($i == $paragraphAfter) { $new_content.= ‘<div style=”width: 300px; height: 250px; … Read more
Here is a working solution (tested as is) The HTML (could be part of page content) <input type=”text” name=”keyword” id=”keyword” onkeyup=”fetch()”></input> <div id=”datafetch”>Search results will appear here</div> The JavaScript ( goes to your theme’s functions.php ) // add the ajax fetch js add_action( ‘wp_footer’, ‘ajax_fetch’ ); function ajax_fetch() { ?> <script type=”text/javascript”> function fetch(){ jQuery.ajax({ … Read more
Customize WordPress Media Manager – Media Window
in your html add `<input name=”action” type=”hidden” value=”test_function”/>` here “value” is your “action_name”. Your ajax call is incorect. Data should be url: “your php action script” data: $(html data).serialize(), About ajax first try to create ajax on your computer without wordpress. When you understand how ajax work try on WordPress.
Handle built in sizes right I wrote a class that handles all the different stuff for built in image sizes. To redefine the built in sizes, use an extended class (the upper file in the linked source) To unset a class and skip it’s useage completely, just set w & h to 0. http://static.steffenvogel.de/wp-content/uploads/2011/07/octocat_construction.gif Click … Read more