As pointed by @mmm, I just needed to change the ‘append()’ for ‘html()’. And the use of ‘-‘ instead of ‘_’ in the ‘action’ part.
I asked him to post it as an answer so I could close the question, but I guess he didn’t see.
So, my final AJAX code is:
$("#opt_filter").change(function () {
var opt_filter = $("#opt_filter").val();
$.ajax({
type: "POST",
url: clocal.ajaxurl,
dataType: "json",
data: {
'action': 'load-filter',
'opt_selected': opt_filter,
},
success: function(response) {
$("#list-of-posts").html(response);
//return false;
}
});
});
Related Posts:
- AJAX search on post pages by custom post type
- Development of a WordPress Search Plugin – Best Practices
- Updating custom post meta with ajax
- Favouriting a Custom Post Type
- WordPress post sorting with AJAX
- Prevent reload confirmation after AJAX save
- is_singular() not working if called via callback function of admin-ajax.php
- How to filter post data with AJAX on page?
- Debug whats going on inside a function called from AJAX
- Get all posts from custom post type and insert in select input as metabox
- Is there an easy way to AJAX-ify saving of post?
- Ajax filter with custom taxonomies
- Filter posts with ajax form and checkboxes
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- How to use wp_mail in CPT page
- Select menu should display categories and the item’s depth
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- Ajax form filter post by custom fields [closed]
- How to load custom post archives sub-pages with ajax?
- Display custom post data in sidebar w/ dropdown
- Getting the URL of the parent page
- Creating select dropdown with parent-level custom post types
- Ajax Check Post Status
- I have 2 post types i need to show the post type contents in 2 select boxes [closed]
- Received nothing after executing AJAX post function
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- Loading custom content type from ajax results?
- Why is my select meta data not saving?
- Widget: Custom Post Type Post Listing Dropdown on Admin Side
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- AJAX load more for different custom post type loops
- Ajax Custom Post Filter is not filtering
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Custom post type – use ajax to display sub pages
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Load Custom_post_type categories post with ajax
- Dynamic Custom Fields
- Load Next Posts With AJAX not working with custom post type
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Retrieve custom post types by custom taxonomies with WP_Query
- $post not working working in AJAX plugin with custom post type
- Load Next WordPress Posts With AJAX?
- Custom post type’s extra fields – how to handle?
- Getting 400 Bad Request on AJAX Call
- admin-ajax.php GET custom-post titles
- Add “Select All” to custom taxonomy
- Post will not load via ajax
- Select2 AJAX and WP Query Returns ALL and does not filter
- echo selected value from dropdown
- ajax response not recieving
- Metabox multiple custom post select -> display selected items?
- Getting a GET error in console – 404 not found for wp-json
- WordPress notification if new post published
- filter by custom taxonomy using ajax
- passing values from functions.php to template
- How do I update_post_meta() or add_post_meta() with an AJAX call
- Multiple wp_editor instances in custom post type using Ajax
- Change Post Meta via AJAX from the posts list table
- Display custom-post type based on the Title matching the current selected value
- WordPress custom post type numeric pagination with ajax
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- WP_Insert_Post creating duplicate posts when logged in
- Not saving custom taxonomy while using ajax
- Search for custom field input of a custom post type in ajax live search
- Filtering posts based on three taxonomies
- WordPress next post by ajax call on button click
- Trying to list years (for a filter) but not all years display
- show label text of select option rather than its value in cmb2
- Use a template for a specific url slug without creating a page
- How to submit the date with ajax?
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- Attend event form with ajax
- WordPress custom post type post item data – show/fetch only on click with Javascript dynamically?
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- How to display custom post type pagination buttons when processing AJAX request
- My post loop needs to have 8 different post templates
- Show ajax form resuslts in page
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- put a list of one post type in other post type to select from it and display selected item in second post type’s single page
- Ajax load more inside custom post type taxonomy
- Is there a best practice, or typical way to do AJAX updating for data on a custom admin screen or post.php?
- Filtering custom post using Ajax and taxonomies, keep getting 0
- Fetch loop of custom post types with AJAX
- Collect custom post in a calendar
- Calling in Post Content via AJAX
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Updating custom post meta with ajax
- Custom filtering on month value only of an entire date field
- Select Menu for Custom post Type does not save
- Repeatable custom meta select boxes
- Create a page selector using taxonomies
- Two different archive pages showing the same content
- update custom taxonomy with Ajax in edit.php file [duplicate]
- Issues on saving data from CPT select metabox
- How to filter custom post data with AJAX?
- Internal Server Error when echoing an OBJECT from wp ajax action function in functions.php to JS file
- Load posts via AJAX without draft status