Add Item to Custom TinyMCE Menu

addMenuItem() adds to tinymce’s toolbar, which isn’t used by WP by default, and uses context to add to the particular (sub)menu. You’re adding a MenuButton, and you can access the button through the editor’s buttons array, keyed by the button name: add_action( ‘admin_print_footer_scripts’, function () { ?> <script type=”text/javascript”> jQuery(function ($) { tinymce.on(‘SetupEditor’, function (editor) … Read more

Javascript not working?

The “Failed to load resource” is probably a red herring and isn’t related to your issue. The fact that it is throwing an error about the $ shortcut means your js file is being loaded correctly. The likely issue is that jQuery in WordPress loads in “noConflict” mode. As such the $ shortcut will not … Read more

JavaScript, best way to use data from the loop

You can use WP_Query to get almost any post data out of your WordPress install. $sub_pages = new WP_Query( array( ‘post_parent’ => 3, ‘post_type’ => ‘page’ ) ); print_r($sub_pages->posts); This would get you the following: Array ( [0] => WP_Post Object ( [ID] => 94 [post_author] => 1 [post_date] => 2015-08-20 11:19:27 [post_date_gmt] => 2015-08-20 … Read more

How to replace a javascript select box onchange event to a form submit action?

It’s not working because: You are redirecting home You don’t listen for the $_GET variable so the archive link is just appended to your home url You need to add a function that listens for that $_GET variable. just add this to your functions.php file add_action( ‘template_redirect’, ‘wpse_archive_select’ ); function wpse_archive_select(){ if( isset( $_GET[ ‘archive-dropdown’ … Read more

Merge two separate WP menus into one in Mobile view

I had the same problem. The solution I chose was to “merge” the menus by placing them under a single div wrapper but have them on separate div class. Something like this: <div class=”menu-wrapper”> <div class=”menu1″> <?php wp_nav_menu( array( ‘theme_location’ => ‘menu-1’, ‘menu_id’ => ‘top-menu’, ) ); ?> </div> <div class=”menu2″> <?php wp_nav_menu( array( ‘theme_location’ … Read more

Create user from outside WordPress through api?

This does not use the API, but it’s a script I’ve used a hundred times over the years, always works. Simply drop it in the root of your install and then access the file directly. Remember to delete the file immediately afterward. I do not remember where I originally obtained this script. <?php // ADD … Read more

How to avoid redefining requirejs in plugin when another plugin also uses requirejs

You could take a look at the enqueued scripts in $wp_scripts ($wp_scripts->registered), but the naming could be different (“it’s requirejs but let’s call it loadstuffjs, just because”), so I doubt it’ll be close to perfect. Also, your plugin might be loaded before the other plugin, and they might trigger the problem without you having any … Read more