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. Implement AJAX ‘load more’ with offset posts
  65. Why sorting posts doesn’t work properly?
  66. How to bulk Update URLs to new values?
  67. Select another post in a post meta like a parent page is selected while editing a page
  68. SQL DELETE multiple post_meta on single and multi-sites
  69. WordPress sorting posts by date and title using a dropdown
  70. Change Old WordPress Post Date Year
  71. the wp_post_update isn’t working all the time
  72. How to fetch courses in all languages in WordPress?
  73. Function is printing twice – any suggestions?
  74. Display/Filter post using if else statement
  75. How to sort WP_Post Object array by object field in php?
  76. Search results for ACF data
  77. Passing values via an Ajax querystring
  78. Query prints posts without specific categories
  79. Private post caught in endless redirect loop
  80. Use WP_query to match post types based on custom field values
  81. Unable to delete attached file from folder programmatically
  82. Javascript – How do I get specific post fields?
  83. How to create custom search form function including post “tags”
  84. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  85. What is proper filter or hook action to add data to the $post object?
  86. Performance considerations – postmeta table versus new table for custom posts with foreign keys?
  87. how to filter posts by category without page load (ajax) in wordpress?
  88. Display specific posts based on an ID of another post
  89. Numbered Pagination Showing The Same Posts After Altering WP_Query
  90. Order by meta_key field in WordPress not meta_value field value
  91. a WordPress connected to 2 database
  92. How to display particular set of wordpress post on a webpage?
  93. How to show post views shortcode data for each post on Posts List Page?
  94. query posts with selected post ids first
  95. Ajax: load content from post I clicked
  96. Change URL of previous posts and next posts link in WordPress
  97. WP Ajax returning 0, can’t find action
  98. How to invoke a HTML custom button based on a HTML dropdownlist menu
  99. How to create page with post content in it?
  100. Blogposting Schema & Structured Data without plugin
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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