Editing existing pre-created menus in PHP

I’ve found a solution to my problem by going over the documentation again and again, looking through source files and just generally running the same section of code over and over to scrutinize the output. This is the solution I came up with, which works just perfectly for my needs: // Get a list of … Read more

How to change text in a page by utilizing a custom user id?

You could use a function like so: function construction_intro( $id = ”, $echo = true ){ $id = absint( $id ); switch ($id) { case 123 : $name = “Hillary’s”; $location = “Washington D.C.”; break; case 9999 : $name = “Bernie’s”; $location = “Burlington”; break; case 47679 : $name = “Donald’s”; $location = “New York”; … Read more

How to get, in WP page’s script, a wp enqueued script (in Functions.php)?

You have to make sure your script is registered with wp_register_script before your call to wp_localize_script. So in your functions.php file: add_action(‘init’,’my demo_function’); function my demo_function() { // Register the script wp_register_script( ‘myuserscript’, ‘path/to/myscript.js’ ); // Localize the script with your data $theid=get_current_user_id(); $params = array( ‘userid’ => $theid ); wp_localize_script( ‘myuserscript’, ‘MyUserParams’, $params ); … Read more

Adding javascript to header of MetroMagazine theme

Don’t edit theme files. Your changes will be overwritten when your theme updates. Instead use a child theme and hook into the wp_head function. Add this to your child theme’s functions.php file. function add_js() { ?> <script> Your JavaScript goes here </script> <?php } add_action(‘wp_head’, ‘add_js’); BTW, as you have a commercial theme, you can … Read more

adding script tag in head of specific pages

A simple google search can help you do this, well same question was answered before, you can see the answer here. Use WordPress methods in your functions.php to do this : function load_scripts() { global $post; wp_register_script( ‘home’, get_template_directory_uri() . ‘/js/home.js’, array(‘jquery’)); wp_register_script( ‘about’, get_template_directory_uri() . ‘/js/about.js’, array(‘jquery’)); wp_register_script( ‘somepost’, get_template_directory_uri() . ‘/js/somepost.js’, array(‘jquery’)); if( … Read more

style.min.css code issue

You can tell by the ID on the <link href=”https://wordpress.stackexchange.com/questions/287569/… tag that the stylesheet”s ID is mesmerize-style, so you should be able to dequeue with this function in your child theme. wp_dequeue_style( ‘mesmerize-style’ ); Make sure it’s hooked into wp_enqueue_scripts with a higher priority than the parent theme’s hook (probably 10). That’s the general answer … Read more

how to call other plugins once custom post has been inserted

I don’t completely understand your question – maybe this will help: wp_insert_post(array( // your woocomm post being inserted )); // at insert, `save_post` will fire add_action( ‘save_post’, ‘my_plugin_save_post’ , 10 , 3 ); function my_plugin_save_post($post_id, $post, $update) { // check other firing of this: if this is a revision, get real post ID if ( … Read more

Add Custom Taxonomy into Script

I think you should use json_encode in the page that you would like to run. Here is some ideas how you to solves. add_action(‘admin_init’, ‘my_taxonomy_list’); function my_taxonomy_list() { if (specific_page) { //check not to run in other pages $taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { $tax_list[] = $taxonomy->slug; } ?> <script> var … Read more