making a simple plugin

Welcome to Stackoverflow. I think First of all you need to learn How to Google search. After that you can start writing your plugin. Well Here is the WordPress Plugin Handbook https://developer.wordpress.org/plugins/. As it states The Plugin Developer Handbook is a resource for all things WordPress plugins. Whether you’re new to WordPress plugin development, or … Read more

WP Offload S3 Lite “Please setup GD or ImageMagick” noticed

Create a file called phpinfo.php in your DocumentRoot <?php phpinfo(); ?> Run it from the command line (php phpinfo.php), check for the gd section. If the gd section is missing, you didnt install gd. Now run the same file from the browser (http://domain.com/phpinfo.php) and again check the gd section. My guess is that the browser … Read more

wp_query on search results page showing all results every time

Don’t create a new WP_Query. As per the template hierarchy WordPress uses the search.php template in your theme for the search results page. This template just needs to contain The Loop, and the only posts inside that will be your search results. See Twenty Seventeen’s search results template as an example: https://github.com/WordPress/twentyseventeen/blob/master/search.php

How to get sub items of parent menu item?

As a workaround I have this temporary solution: $the_menu = wp_get_nav_menu_object(‘Some Menu’); $the_menu_items = wp_get_nav_menu_items($the_menu); $category_products = []; foreach ($the_menu_items as $index => $menu_category) { if ($menu_category->object_id == $category->term_id ) { $category_submenu = $menu_category; } } foreach ($the_menu_items as $index => $menu_product) { if ($menu_product->type_label == ‘Product’ && $menu_product->menu_item_parent == $category_submenu->ID ) { $category_products[] = … Read more

How to display blog posts only authored by the administrator

Four changes to your script. Limit $users to users with ‘administrator’ role. Removed line if($user->caps[‘Administrator’]!=1) continue; as every user is an administrator. Changed ‘post_per_page’ to -1, to process all posts. Added wp_reset_postdata(); after each loop: $users = get_users( array( ‘role’ => ‘administrator’ ) ); foreach ( $users as $user ) { $query = new WP_Query( … Read more