Conditional Tags – Multiple Categories

As Mayeenul said in the comment you can use: if($category[0]->name == ‘News’ || $category[0]->name == ‘home-news’) { … And to follow up on your comment about the title flashing in, this is because the jQuery is run after the browser has already rendered the content so there’s a brief moment when it’s shown before jQuery … Read more

Can’t execute jQuery before my script

Try two things – 1. Link your js using wp_enqueue_script action as under : add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ); function theme_name_scripts() { wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(‘jquery’), ”, true); } Third parameter in wp_enqueue_script() function will make sure jquery is loaded before your current js file. Inside your js file, replace $ with jQuery as … Read more

Duplicate “default” form with jQuery

I don’t know your html code, but here is how it will work. The idea is that you keep the original hidden elsewhere. HTML <button class=”add-form”>add form</button> <form id=”main-form”> <div class=”form-item row”> <input type=”text” name=”abc”> </div> </form> <div class=”stay-hidden original-form-item”> <input type=”text” name=”abc”> </div> CSS .stay-hidden { display:none; } JS // Add form jQuery(‘.add-form’).click(function() { … Read more

Bootstrap modal with jQuery post [closed]

If process.php is not found, your reference in the file is not correct. Make sure you reference to the correct path, for istance – if the file is in the rootdirectory of your site, add a slash in front of your code: url: “process.php”, will be: url: “/process.php”, If it is in the ‘ajax’ directory: … Read more

Applying jquery to WordPress admin edit.php

The previous answer works good with my example above using this hook: add_action( ‘admin_head’, ‘woocommerce_admin_init’ ); function woocommerce_admin_init() { $screen = get_current_screen(); if ( $screen->post_type == “shop_order” ) { ?> <script type=”text/javascript”> jQuery(document).ready(function ($) { $(“.edit_address”).click(); $(“.add-line-item”).click(); }); </script> <?php } }

Delete post image attachments with jQuery from the front end

Now you need to handle the AJAX call in PHP. add_action( ‘wp_ajax_delete_attachment’, ‘delete_attachment’ ); function delete_attachment( $post ) { //echo $_POST[‘att_ID’]; $msg = ‘Attachment ID [‘ . $_POST[‘att_ID’] . ‘] has been deleted!’; if( wp_delete_attachment( $_POST[‘att_ID’], true )) { echo $msg; } die(); } As for your event, just add it to the click function … Read more

Custom AJAX form not working async

First probable issue: You’re using name in the form. You should not, since it’s a reserved term in WordPress. Second probable issue: You’re using a form action URL of <?php echo get_template_directory_uri(); ?>/assets/php/process-contact.php. That will break if you use any WordPress functions (or functions defined in functions.php and plugins). This is the correct way to … Read more

WP Customizer: Save a control state

Found a solution. Turns out the activate, deactivate functions are not persistent, meaning the controls’ state are reset if the page is refreshed! Therefore I used ‘active_callback’ => ‘fname’ in my customizer.php in order to make changes persistent where fname is the function name as seen below. function fname() { if ( !strcmp ( get_theme_mod(‘above-header’), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)