Generating embed code for users to share

Try following code. This will display embed code in the bottom of the page. <?php add_filter(‘the_content’,’my_custom_embed_code’); function my_custom_embed_code( $content ){ global $post; if ( ‘page’ == $post->post_type ) { $embed_code=””; $page_url = esc_url( get_permalink($post->ID ) ) ; $embed_code .= ‘<object data=”https://wordpress.stackexchange.com/questions/160604/.$page_url.” width=”100%” height=”500″><embed src=”https://wordpress.stackexchange.com/questions/160604/.$page_url.” width=”100%” height=”500″></embed> Error: Embedded data could not be displayed. Visit <a … Read more

Loop through arguments of a function

wp_enqueue_script states the parameters type respectively as string – string – array – string – boolean. As you pass an array as the second parameter, the error occurs. Now, comparing your $array data, you can handle it extracting the array or using array key/value. – public function loadScripts() { $themeScripts = iarray( ‘custom’ => array( … Read more

How to include a JS file in this theme?

From wp_enqueue_scripts action: wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end. For admin-facing scripts, the correct action hook is admin_enqueue_scripts function prefix_enqueue_scripts3() { wp_enqueue_script( ‘metabox_js’, get_stylesheet_directory_uri() . ‘/js/metabox.js’, array( ‘jquery’ ), ‘1.0.0’, true ); } add_action( ‘admin_enqueue_scripts’, ‘prefix_enqueue_scripts3’ );

How can I remove the site URL from enqueued scripts and styles?

Similar to Wyck’s answer, but using str_replace instead of regex. script_loader_src and style_loader_src are the hooks you want. <?php add_filter( ‘script_loader_src’, ‘wpse47206_src’ ); add_filter( ‘style_loader_src’, ‘wpse47206_src’ ); function wpse47206_src( $url ) { if( is_admin() ) return $url; return str_replace( site_url(), ”, $url ); } You could also start the script/style URLs with a double slash … Read more