oEmbed Video in Modal
Okay, I’ve got around this by simply hiding the div containing the oEmbed code and then using .clone() to replicate it into my modal when it pops.
Okay, I’ve got around this by simply hiding the div containing the oEmbed code and then using .clone() to replicate it into my modal when it pops.
Figured it out by using the following jQuery function. The #protocol_relative is the field I am inserting and #home-description is the field I am inserting it after: add_action( ‘admin_footer’, ‘insert_field’ ); function insert_field() { # Insert the settings field after the ‘Site Address (URL)’ ?> <script type=”text/javascript”> jQuery( ‘#protocol_relative’ ).closest( ‘tr’ ).insertAfter( jQuery( ‘#home-description’ ).closest( … Read more
You have to use AJAX for that. What you have to do is: Create a JS script which sends an AJAX request to admin-ajax.php file: <script> jQuery(“.author-popup”).on(“click”, function(){ var id = jQuery(this).attr(“id”); jQuery.post(“http://www.yourdomain.com/admin-ajax.php”, {action: “my_author_box”, id: id}, function(response){ console.log(“Response: ” + response); //NOTE that ‘action’ MUST be the same as PHP function name you want … Read more
Try this -> jQuery(document).ready(function($) { $(‘#menu-main-menu a’).click(function( event ){ var visibleSubmenu = $(‘#menu-main-menu ul.sub-menu:visible’); var submenu = $(this).next(‘ul.sub-menu’); if( submenu.length >= 1 ) { event.preventDefault(); visibleSubmenu.slideUp(); submenu.slideToggle(); } }); });
I always refer to to this blogpost about how to including jQuery code in WordPress. It shows you how to use noConflict within your javascript-code. var $j = jQuery.noConflict(); $j(function(){ // YOUR CODE HERE } } Also make sure that the jQuery library is included on the frontside of your WordPress installation with the wp_enqueue_script-function. … Read more
Yes, this should be correct. Is_single returns true on single post pages, both normal and custom post types. Note that if you also want to run your script on pages, you will need is_singular. The latter allows you to specify which post types the script should be included with, so it gives you more flexibility. … Read more
To get a permalink you need to use get_permalink(). Just pass the ID of the post or leave it blank to get the current page in the Loop. wp_localize_script () will render PHP variables on the page that are consumable by JS through a global object that you define. PHP // Register the script wp_register_script( … Read more
Assuming the letters are links, then put the letter into the URL as a parameter. E.g.: http://example.com/brands/?letter=N Then, in the code (inside whichever template file will be used here), you need to query the DB for posts/brands beginning with ‘N’. You can either create a taxonomy for letters (https://codex.wordpress.org/Function_Reference/register_taxonomy) and assign each post to a … Read more
Initialize the Scroll to Top script from within another JavaScript file. I’m assuming that jquery.backtotoplink.js is coming from a third party and that it should not be modified. For example, in a theme, the JavaScript could be enqueued like this: function wpse247853_scripts() { // jquery.backtotoplink.js depends on jquery wp_enqueue_script( ‘scrolltotop’, get_template_directory_uri() . ‘/js/jquery.backtotoplink.js’, array( ‘jquery’ … Read more
To properly enqueue jQuery, it’s usually done with wp_enqueue_scripts, there’s no need to load it from cdn as jQuery library are provides in the wp-includes folder of WordPress. Only wp_enqueue_script(‘jquery’); is required. add_action(‘wp_enqueue_scripts’, ‘replace_jquery’); If you really want to replace jQuery with the cdn link, it’s better to register and enqueue it with this function.