Calling function in loop causes repeat data

first of all, you could delete the return $ranking += 1; and replace by $ranking += 1;. We don’t know what happend in the template-parts/content, but don’t forget to add a little <?php wp_reset_postdata(); ?> just after your endwhile;.

calling function in external js file

i think the script.js file is not loading properly. if its loading then the function should work as expected. are you referencing the complete path of script in your script.js call? like <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/256287/some-domain.com/path/widget.js”></script> try opening that file from page source and see if its loading the correct js file? its always best practice … Read more

How to delete a theme using AJAX

You can do this by creating a post form with a nonce field… $url = admin_url(‘admin-ajax.php’); echo ‘<form action=”‘.$url.'” method=’post’>’; echo ‘<input type=”hidden” name=”action” value=”delete_theme”>’; wp_nonce_field(‘updates’); // to pass check_admin_referer echo ‘<input type=”hidden” name=”slug” value=”twentythirteen”>’; echo ‘<input type=”submit” value=”Delete TwentyThirteen Theme”>’; echo ‘</form>’; You can replace the hard-coded slug input field with a <select> one … Read more

Alter Woocommerce product archive structure

I think the subcategory thing get generated with this function woocommerce_product_subcategories();. But as you said for this layout there is no specific template file. Also, if I remember right, you cannot do this with css alone. A little while ago I created a little plugin for a customer who also wanted a product overview structured … Read more

Output category list inside array

Try something like the following. Notice that the hide_empty argument is set to false. $args = array( ‘orderby’ => ‘id’, ‘hide_empty’=> false, ); $cats = get_categories($args); foreach ($cats as $cat) { // Your code to populate new array here } And then assign your newly created array to values.

How to display the content only to the allowed IP address [closed]

I have tried your code and its working fine for me. <?php $allow = array(“xxx.xx.xxx.xxx”,”xxx.xx.xxx.xxx”); //allowed IPs if(!in_array($_SERVER[‘REMOTE_ADDR’], $allow) && !in_array($_SERVER[“HTTP_X_FORWARDED_FOR”], $allow) && !in_array($_SERVER[“HTTP_CLIENT_IP”], $allow)) { ?> <div class=”enclose comn-pg”> <h1 align=”center” style=”padding:10% 0;”>Access denied. This page is accessible only to customers.</h1> </div> <?php } else { ?> <div class=”enclose comn-pg”> <div id=”primary”> <div id=”content” … Read more