Enqueing External JS on the remote server JS

You use $ in custom.js file and probably that’s the reason, because jQuery is included in WordPress in noConflict mode. You can replace $ with jQuery in custom.js or wrap the code as shown below: (function( $ ) { // — your code — $(document).ready(function() { //… }); })(jQuery); Or jQuery(document).ready(function($) { // code from … Read more

Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file

(Revised answer) So I’m assuming that there are actually posts in the category (ID: 31), and based on the wp_get_post_terms() reference: $post_id (int) (Optional) The Post ID. Does not default to the ID of the global $post. Default 0. It’s likely that you’re not passing the proper post ID to the wp_get_post_terms() function: wp_get_post_terms( $post->ID, … Read more

Contact Form 7 If Condition

Yes, you should be able access the form fields and field values with event.detail.inputs in addEventListener on wpcf7mailsent. You can then use the field values in the conditional statements and add the redirects you need. There’s a simple code sample in the plugin doumentation, https://contactform7.com/dom-events/, for looping the fields. EDIT Here’s a code example, document.addEventListener( … Read more

Filter to wp_list_authors

wp_list_authors(), displays a list of the sites’s authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts. Use $authors = get_users( [ ‘role__in’ => [ ‘auther’] ], // add other parameters ); Then loop through $authors to create your own list. foreach ( $authors … Read more

How can I count ACF sub_field with a certain value

PHP’s count() function is generally used to count elements in an array, but you’re counting the value of a string, and that always returns 1. You can just add 1 in your if statement. Something like this: if (have_rows(‘candidates’)): $total = 0; while (have_rows(‘candidates’)): the_row(); $position = get_sub_field(‘candidate_position’); if ($position == “Mayor”) { $total++; }; … Read more

add_query_arg not work in admin

some_body needs to be run as an action on pre_get_posts. Here’s an example of the entire process of adding new query vars. Pay extra attention to myplugin_pre_get_posts: function myplugin_pre_get_posts( $query ) { … $city = get_query_var( ‘city’ ); … } add_action( ‘pre_get_posts’, ‘myplugin_pre_get_posts’, 1 );