Create a new post using rest api and save featured image using an external image url

Instead of using wp_ajax_ (i.e. admin-ajax.php), how about adding a custom REST API field and then using its update_callback, download the remote image and set it as the post featured image? Working Example add_action( ‘rest_api_init’, ‘wpse_381217’ ); function wpse_381217() { register_rest_field( ‘post’, ‘featured_image_url’, array( // If you don’t want to expose the field in the … Read more

Ajax category filtering products default show all

First, you should use the REST API for frontend instead of admin-ajax. Second, you should not use unfiltered POST values. And for your products on page load, you should tell your Javascript to fill the ID “response”, when the ID is present. Now, you only load products, when the click event on the class js-filter-item … Read more

Ajax Custom Post Filter is not filtering

How to make your AJAX filter works properly: As I said in the comments, add the data-category attribute to the <a> having the CSS class js-filter-item in the foreach loop in your archive-projetos.php template: // * Wrapped for brevity. foreach ( $categories as $cat ) : ?> <li><a class=”js-filter-item” href=”<?= get_category_link( $cat->term_id ); ?>” data-category=”<?= … Read more