Modal opens all post IDs

So your script is doing exactly what you have told it to do. Here you are passing the element to the function, but you never use it, instead you just query all elements with a class and add another class. function moreinfoModal(field) { console.log(field.id); $(‘.moreinfo-modal’).toggleClass(‘open’); } What you should do is only add the class … Read more

How do if all posts has this category ID then do this

You can use get_category( $id ), the object it returns includes a count of posts contained in this category. To build on your example, this would be: $my_category = get_category( ’25’ ); if ( 1 <= $my_category->category_count ) { echo “OK”; } else { echo “NO OK”; }

Set user status to absent on WordPress

You are going to have to add some Javascript to the page that will check for a timeout. Remember that PHP is executed on the server, and the servers sends HTML to the visitor’s browser. One the page is generated, the server doesn’t do anything until the next request comes from that visitor (or anyone … Read more

WooCommerce multiple custom fields code

Not in stackoverflow nor stackexchange can`t answer my question. I dont know maybe they just can edit my writing dictation!. Anyway after searching in php courses my code is this now and works correctly: <?php $custom_field_type = get_post_meta($post->ID, ‘_custom_field_type’, true); $custom_field_type = array_filter($custom_field_type, ‘strlen’); if (count($custom_field_type)) { echo ‘<div id=”vijegiha”>’; echo ‘<h3 id=”vijegih3″>ویژگی های کلیدی</h3>’; … Read more

Advertisement in Loop Posts wordpress

Use WP_Query and then loop the results using break when you want to stop to put the ad. $args = [ ‘posts_per_page’ => 5 ]; $posts = new WP_Query($args); Then loop 2 <section class=”posts”> <?php $cont = 0; ?> <?php while( $posts->have_posts() ) : $posts->the_post(); $cont++; $id = get_the_ID(); //Show your post here if($cont >= … Read more

ajax polling with admin-ajax.php

You idea is equivalent to DDOSing your site, and the difference between the methods is only how fast you will bring the site down. WordPress AJAX handling is expensive, and should be limited to user initiated actions. Your second method will be more resilient but you are still going to be wasting server resources as … Read more

Get field in readable word

(Updated/new answer) How to make it show “United States (US)” instead, on the frontend, in a shortcode? First off, you got united-states (the country slug/key) instead of United States (US) (the country name) because your extrainfo_save_extra_user_profile_fields() function is saving the country slug/key instead of the country name. That’s not a problem, and I’d do the … Read more