WordPress Stats Plugin: Display Post Views [closed]

Put this into your functions.php file: function userfunc_get_post_views($postID) { global $post_stats; foreach ( $post_stats as $p ) { if ( $p[‘post_id’] == $postID ) { ?> <span class=”stats-post-views”> <?php echo number_format_i18n( $p[‘views’]) . ‘ views’; ?> </span> <?php } } } and then into your single.php file where you want the views to be displayed: … Read more

Removing admin javascript

According to the load-scripts.php file, scripts that are not enqueued will not be loaded, so I don’t need to worry about it when using hooks like admin_enqueue_scripts and the wp_deregister_script function. foreach( $load as $handle ) { if ( !array_key_exists($handle, $wp_scripts->registered) ) continue; However, my problem with jQuery week calendar was with the wp-jquery-ui-dialog style. … Read more

How do I pass $in_foooter to wp_enqueue_script() without passing other params?

Try passing array() for $deps, and NULL for $ver: wp_enqueue_script( $handle, $src, array(), NULL, $in_footer); Or, using your function call: wp_enqueue_script(“myscript” , get_template_directory_uri().”/js/myscript.js”, array(), NULL, true ); By the way, passing the script itself as a dependency to itself will probably make something blow up. Note also: if your script depends on jQuery, just pass … Read more

Automatically add a character to field in edit post page

Here is one idea: You could try to fire the change event of the #location-address (for example) input text field when the page has loaded: function custom_jquery() { echo “<script>jQuery(document).ready(function(){ jQuery(‘#location-address’).on( ‘change’, function( event ) { console.log(‘debug: on change fired!’); }); jQuery(‘#location-address’).change(); });</script>”; } add_action( ‘admin_head-post.php’, ‘custom_jquery’ ); if your editing page is post.php. You … Read more

JavaScript Libraries in WordPress

This is how you should do this: function my_scripts_method() { wp_enqueue_script( ‘pikachoose’, // this is your custom name for this JS lib get_stylesheet_directory_uri() . ‘/js/pikachoose/jquery.pikachoose.min.js’, // this is the url address of it’s file (let’s say you put it in your theme directory under /js/pikachoose/ directory array( ‘jquery’ ) // it depends on jquery ); … Read more

is there a way to get all queued scripts/styles into a template without `get_header()`?

the_header() does not even seem to be native WP function? Technically getting header isn’t what really causes styles and scripts to load, it’s wp_head() call that should be made there (and wp_footer() call in footer). So they are likely what you should be using. If you do need something lower level you might want to … Read more

WP_ENQUEUE not working with Foundation 5

EDIT: I’m coming back to correct this post, having successfully wp_enqueue’d Foundation 5.3 for Sites to WordPress 3.9. This code below is for anyone who has struggled to WP_ENQUEUE Foundation. The code below works perfectly. UPDATES: I will continue to update this post with the newest version of WordPress and Foundation to give you all … Read more

Generating a static page from a script

I don’t know how one would define “best”, but a possible approach would be to make your rankings page an actual page within WordPress, then add either a shortcode or a filter on the_content to populate/fetch a transient from the database. You could alternately save it in an option or as post meta and cron … Read more

What do I need for testing a single script in admin

Sounds to me like you’re trying to create a custom Admin Page. Instead of adding a file into the admin folder, you can create custom admin pages from your WordPress plugin or theme by using the ‘Admin Menu’ action. In short, you will need to add something like the following to your plugin, or your … Read more

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