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

Ajax: Populate with content from a post’s ID not working – duplicating current page html instead

First, you made a really, really silly typo:

'ajaxurl'   => admin_url( 'admin-ajax.php' ),
.....
url: funnel_ajax.ajax_url,

ajaxurl != ajax_url. So your Admin AJAX request is not returning a full HTML page. You’re not even hitting the AJAX file!

However, this is still completely the wrong way to go about this


I was going to suggest that you instead use the REST API which is much easier and foolproof, and to write a custom endpoint using register_rest_route to give you a pretty URL such as example.com/wp-json/richerimage/v1/dnafunnel, but you don’t need to.

In fact, you don’t even need an AJAX handler or an endpoint. Just use the one that core gives you.

First, register the post meta so it appears in the REST API responses:

PHP:

$args = array(
    'type' => 'string',
    'description' => 'DNA Funnel Info thing',
    'single' => true,
    'show_in_rest' => true,
);
register_post_meta( 'post', 'dna_funnel_info', $args );

Then retrieve the desired post, e.g. example.com/wp-json/wp/v2/post/123 where 123 is the ID of the post you wanted. The JSON response will contain the content in its fully rendered form, title, taxonomies, etc, including a meta section with all the meta keys you registered.

If your post ID is for a CPT, make sure show_in_rest is set to true when it’s registered, and replace /post/ with the relevant endpoint for that CPT

Or better yet, use PHP:

add_filter( 'the_content', function( $content ) {
    // append post 123's content to the end
    return $content . get_the_content( '', '', 123 );
} );

Related Posts:

  1. ajaxurl not defined on front end
  2. Why does WordPress use outdated jQuery v1.12.4?
  3. How to include jQuery and JavaScript files correctly?
  4. jQuery in header or footer
  5. How to Add a .js file Only in one specific Page Dynamically to Head
  6. How to enable users to down-vote in this simple voting counter (that uses the post meta)?
  7. Using Ajax call in jQuery doesn’t work in widget
  8. WP_LOCALIZE_SCRIPT doesn’t work
  9. What is the difference between these two methods of writing $ instead of jQuery in WordPress [closed]
  10. Admin-ajax.php appending a status code to ajax response
  11. Ajax in WordPress – path issue
  12. how to search users by ajax live search
  13. WordPress custom taxonomy check box to dropdown
  14. Update Data parameter of a wp_localize_script() call
  15. WP Plugin Running before jQuery
  16. jquery & ajax sending data to php
  17. 400 Bad Request, in wordpress theme development, wp_ajax
  18. Ajax submit result opens in admin-ajax.php
  19. insert query on a custom table using ajax with jQuery plugin Jeditable
  20. Data not insert and update through ajax and jQuery in admin page?
  21. WP ajax requests not stacking?
  22. Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
  23. ajax working when function is on child theme but not in plugin page
  24. Using function from enqueued .js file in theme in plugin?
  25. Ajax +wordpress onClick link redirect to new page and create html content
  26. Adjust query on single
  27. Get cat parameter from admin-ajax
  28. Ajax on the Administration Side of plugin – returns 0
  29. Jquery php request is returning a weird result
  30. 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
  31. Rate limiting ajax requests in WordPress
  32. WordPress Ajax not returning Response
  33. wp_ajax add_action fuction won’t fire on custom jQuery action
  34. Filterable posts using categories
  35. How to get values from Tinymce visual editor popup?
  36. WordPress function is not called and ajax return 0
  37. Ajax call not working with
  38. Ajax functions – no access to wp-admin.php only online
  39. Page reload occurs before request finishes
  40. Loading jQuery library from WordPress admin
  41. How to get the value entered in the input field in wordpres
  42. How react js and other Javascript Technologies works on WordPress plugin?
  43. Is there a way to add a link with add_post_meta?
  44. Loading Images from Javascript on the Front End
  45. Ajax request sends url rather than data
  46. Setting a post’s category
  47. Using jQuery prepend() with file include
  48. rewrite_rules problem
  49. Using password protection to load different page elements?
  50. How to deal with different jQuery versions?
  51. Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
  52. How can the_excerpt (or equivalent) be called on a category description?
  53. Why does website stretch and white space on load? [duplicate]
  54. WordPress (pagenow link) in ajaxurl change after i change plugin language
  55. Why is $_POST empty when saving custom Meta Box?
  56. Change the behaviour of a button
  57. WP_Query order posts by category
  58. Configuring Xdebug with docker compose
  59. Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
  60. Why my theme’s css not working on another site
  61. How to access index file in Block Themes?
  62. wc_get_template_part doesnt display the content [duplicate]
  63. How to do admin ajax request in a plugin for rest api
  64. How to show comments from different Plugins to same post type?
  65. Pass custom props to
  66. wp.media gallery collection sometimes undefined
  67. Ajax action has 200 status but response of No response data available for this request
  68. escape html in jQuery for WordPress
  69. WordPress Does not grab the string sends useing AJAX response, wp_ajax hook
  70. Query String Filtering API
  71. Include external po file for 3th party plugin to theme
  72. Posts form with AJAX request – Plugin development
  73. WordPress Favicon not Working For Images/Videos/PDFs
  74. Condition to check previous next article post title
  75. How to make premium plugin? I want to limit it until verification
  76. GET request return value as error instead of success
  77. Google Web Core Vitals – management, how to in wordpress and advice
  78. How to add quick edit on the list of users to edit custom fields?
  79. How to control ajax calls without effecting memory of server?
  80. Impossible to declare box-shadow with wp.customize?
  81. Bad request 400 using class based files
  82. register_meta not showing custom post type metabox data in rest api
  83. Want to know how to reveal a WordPress theme, considering the theme name is hidden?
  84. Override category archive page title (not the head title)
  85. Forbidden Error in ajax call with wordpress
  86. How to properly use AWS SES for a contact form?
  87. Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
  88. “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
  89. How do I add filter with woocommerce categories?
  90. ajax stopped working when not logged in wordpress
  91. jQueryUI draggable doesn’t work in WordPress plugin
  92. How to change PHP variables with AJAX request in WordPress
  93. ajax call return 406 not acceptable for non logged users only
  94. Does $this context change in an AJAX callback?
  95. $ is not defined [duplicate]
  96. Can’t upload image via submitting custom post from frontend
  97. Need Help to make a logic for editing posts in Frontend
  98. Redirection from a specific page for users logged in but not with membership
  99. Insert, update or remove data from database (usermeta)
  100. How can we stop showing short code in create or edit post section
Categories plugin-development Tags ajax, jquery, plugin-development, post-meta, theme-development
How to save custom form data in wp_options table
register_post_type()’s rewrite slug not working

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