Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

wp_query with ajax

So, i found a work around for this . I just display the excerpt() and then I link them to the permalink() of this post.

// to load the result from ajax

function filter_post_asb_clone()
{
    // ob_start();
    $args = array(
        'year' => $_POST['year'] ,
        'cat' => array(42 , 43)
    );
    $query = new WP_Query($args);
    if ( $query -> have_posts()) :
?>
    <div class="container">
        <ul class="display-posts-listing">
            <?php while($query -> have_posts()) : $query -> the_post(); ?>
            <a href="https://wordpress.stackexchange.com/questions/328651/<?php echo the_permalink(); ?>">
                <li class="listing-item">
                <h4><?php the_title();?></h4>
                <?php
                    echo the_excerpt();
                ?>
                <?php the_post_thumbnail();?>
               </li>
            </a>
            <?php endwhile ; ?>
            <?php wp_reset_postdata();?>
        </ul>
    </div>
<?php
    endif;
    exit;
}

Thank you very much

Related Posts:

  1. is there a way to show the the post title after the image?
  2. Random ajax load only works with posts_per_page set to -1
  3. How to exclude latest x posts from a paginated query?
  4. Query posts distinct authors
  5. How to get previous 10 days post from a specific date – WP Query
  6. This AJAX Code Doesn’t Work – Looking for elegant solution
  7. Hiding posts in a list from specified categories
  8. How would I get 1 latest post from a query for 5 posts?
  9. Exclude posts with empty post_content in wp_query
  10. AJAX filter posts by year
  11. Improving WP_Query for performance when random posts are ordered
  12. I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
  13. Reset Popular post query?
  14. Ajax load more button in Recent posts widget
  15. WP_Query with ajax handler returns the same posts
  16. Why WP_Query(‘showposts=5’) shows only 1 post?
  17. How can I sort posts by the date and a custom meta field?
  18. Blog post per page setting conflicting with custom WP_Query?
  19. How to exclude latest x posts from a paginated query?
  20. Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
  21. posts_per_page option limits the number of Gallery items
  22. wp_posts table: safely remove unused columns to save database storage
  23. Query Posts by Custom Field
  24. Nested WP_Query breaking loop
  25. WordPress query_posts by tag doesn’t work anymore(?)
  26. why the same code got different results when using query_posts in functions.php and index.php
  27. Query for first 3 posts to change the look and feel
  28. How to get posts published on the latest date?
  29. How to check in functions.php if there is data in a WP_Query?
  30. Shortcode with ‘year’ parameter
  31. On what hook can I get the queried object’s final state?
  32. How to give classname to post if post has no content?
  33. WP_Query: Show 10 posts in date order, first three random
  34. Random posts that always include a particular post?
  35. WordPress post filter menu
  36. Query function not executed between element [closed]
  37. Echo the number of posts being displayed
  38. WordPress query portfolio posts
  39. Display 3 posts with different HTML markup using a loop
  40. Change content off every sixth element
  41. Show posts from two specific category in WP_Query
  42. How to create loop of posts except post ID defined via ACF field
  43. Displaying all posts from other sites on the network on one site
  44. Multisite how to display merged posts from two sites and sort by latest date?
  45. Show 5 posts and than 3 posts offset with pagination
  46. wp_query args with relation
  47. Ajaxify Post Sort
  48. WP_Query sort by meta_value_num or date
  49. WP_Query extended with AJAX
  50. Manipulate query to show specific post
  51. Creating Ordered Query using Meta_key
  52. Sort / Filter Queries
  53. Show posts between two Custom Fields date
  54. How to get only current images of a post
  55. Ordering posts alphabetically by meta keys and title
  56. Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
  57. Why I have this strange behavior when I try to exlude the featured post from posts visualization?
  58. How do I control the fallback query after the original query returned cero posts?
  59. Remove duplicated posts in the loop if post has more than one category
  60. Adding a category at even positions on main loop with modified pagination
  61. wp_query select if have comments
  62. WP_query sort by custom meta_key “price”
  63. query_posts different amount of posts per page [duplicate]
  64. Keep featured content post in homepage with original order
  65. Adding additional data to WP_Post object
  66. Ajax Load More Posts in Category Page
  67. Order post by year DESC and month ASC
  68. Function to show random posts from a category
  69. wp query with dynamic taxonomies and terms?
  70. How do I use `posts_distinct` correctly?
  71. How to find what index page a post is on?
  72. Get Posts that are in the current month or later
  73. WP Query to Get Array of Slugs
  74. Get Meta Key Value While Saving Post
  75. Display all posts that were published before full post on single.php
  76. Hiding Draft Post In Admin
  77. How to verify wp user password by sql query in wp? [closed]
  78. Meta value does not save for scheduled posts
  79. how to change the number of posts returned in a specific loop without making it global?
  80. How to save meta checkbox WordPress
  81. Using AJAX and PHP to load next post object
  82. When WP_Query only returns 1 post, how do I automatically redirect to that post?
  83. WP_Query articles order by offset in collumns
  84. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  85. How to use two query result together in one loop
  86. show loop id post , only first id can read
  87. filter posts based on menu_order
  88. Order result from ajax
  89. wp query custom orderby not custom field
  90. Need help writing loop to display posts by categories in separate divs
  91. Query post category & remove any post id
  92. WP Load post with ajax and apply isotope
  93. Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
  94. How to limit the number of results for all query_posts on mysite
  95. How to query post ids liked by the Author
  96. The next_posts_link() works only with original $wp_query
  97. Not displaying any articles on a custom made file
  98. Site ‘Categories’: save an admin global setting with post metadata [closed]
  99. How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?
  100. Why does ‘get_the_ID’ work outside of the loop?
Categories posts Tags ajax, post-meta, posts, query-posts, wp-query
Block properties, attributes and settings
Restore page after deleting it from trash

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress