Execute inline javascript in wordpress after page fully loaded

I think you should in this case use echo: function print_script() { echo ‘<script type=”text/javascript”> window.onload = function () { var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; alert(loadTime); console.log(loadTime); } var var1 = <?php echo json_encode(‘var1’); ?>; var var2 = <?php echo json_encode(‘var2’); ?>; var var3 = <?php echo json_encode(‘var3′); ?>; </script>’; } add_action(‘wp_print_scripts’, ‘print_script’);

Multiple image selection custom widget

I’ve found a solution by myself! With two lines of code I’m now able to save all the selected images and then retrive them on the front-end. I have added an array in the JS code part: // media library script (function($){ $(document).ready(function(){ $(document).on(‘click’, ‘.upload_image_button’, function(e){ e.preventDefault(); var button = $(this); var file_frame = wp.media.frames.file_frame … Read more

Creating custom “player-objects”

For players you could create a custom post type, like so function my_player_cpt() { $labels = array( ‘name’ => _x( ‘Players’, ‘Post type general name’, ‘textdomain’ ), ‘singular_name’ => _x( ‘Player’, ‘Post type singular name’, ‘textdomain’ ), ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘taxonomies’ => array(‘game’) ‘supports’ => array( ‘title’, // … Read more

Using id to show item

If the GPX file is attached to the current page you can find it with get_attached_media(), e.g. $gpx_files = get_attached_media( ‘application/gpx+xml’ ); if ( count( $gpx_files ) >= 1 ) { echo do_shortcode (‘[sgpx gpx=”‘ . wp_get_attachment_url( $gpx_files[0]->ID ) . ‘”]’); } else { echo ‘<p class=”warning”>No GPX file attached!</p>’; }

Make custom post types using ACF

I don’t believe that custom post types are a part of ACF. I use custom post type generators to add post types. This is the one that I use. You would just need to paste the resulting code at the bottom of your theme’s functions.php file.