Custom route and query

There are 3 issues with your code: The proper syntax of registering your custom REST API route, is as follows: register_rest_route( $namespace, $base_URL, $args, $override ); So: register_rest_route( ‘boss/v1’, ‘/latest-quiz-results’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘get_latest_quiz_results’ ) ); Consult the reference for more information. In the get_latest_quiz_results(), $wpdb is not defined because you’re missing … Read more

wordpress frontend editor to add extra css to website

I think it’s worth studying how other plugins work, for example: Visual Composer. The logic that came into my head, is to pick the element selector clicked with jQuery, and work on it. Read this that may help you: https://stackoverflow.com/questions/5706837/get-unique-selector-of-element-in-jquery Following this logic, if each page element has the same class, it will be easier … Read more

Display attribute on shop page after the title

add_filter( ‘the_title’, ‘YearOfMake’, 10, 2 ); function YearOfMake( $title, $post_id ) { if ( get_post_type( $post_id ) != ‘product’ && ! is_archive() ) return $title; if ( ! ( is_shop() || is_product_category() || is_product_tag() ) ) return $title; /* global $product; $attribute=”year-made”; $abv = $product->get_attribute($attribute); if(!empty($abv)) { $title .= ‘<br /><p>’ . $abv . ‘</p>’; … Read more

Can’t upload CSV file to plugin directory using custom upload form in admin panel

I don’t know what the reason you upload a file to the plugin directory. The standard way to upload a file is to the WordPress uploads directory. In your code, I find this one is wrong $uploadPath = $currentDir . $uploadDirectory . basename($fileName); See, you merge two path together. Try $uploadPath = $uploadDirectory . basename($fileName); … Read more

load more button in plugin

If you want it to work like a true “load more” button, then you are going to have to let the posts load in groups without the user changing pages. This means you have to use an AJAX method. This is much more complicated than the WordPress loop you have right now. Overall it works … Read more

jQuery Ajax PHP function call returning [object Object]

OK, so there are multiple problems with your code… 1. Incorrect localization of script Here’s your function that enqueues and localizes the scripts: function my_theme_enqueue_scripts() { wp_enqueue_script(‘jquery-ui’, ‘https://code.jquery.com/ui/1.12.1/jquery-ui.min.js’, array(‘jquery’), ‘1.12.1’); wp_register_script( ‘myjs’, get_stylesheet_directory_uri() . ‘/my.js’, array(‘jquery’),’1.0.0′); wp_enqueue_script(‘myjs’); wp_localize_script( ‘ajax-script’, ‘admin-ajax’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ) ); } add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_scripts’ ); So you … Read more

My jQuery Ajax form submit is still refreshing page?

You use wrong js event. You register your callback with this code: $(‘#form-pm’).on(‘send’, function(e) { But there is no event called send on form. It should be submit. Here’s fixed version of that line: $(‘#form-pm’).on(‘submit’, function(e) {