As it seems, it’s an easier way, using get_template_part and some php magic.
What you do is get the page name from post_metadata filter the filename without the extension and add it to get_template_part. Of course all your data must conform a predefined variable (or just pass the id to the template) because you have to use a global $post or a global $ID on the page template to retrieve that variable.
Related Posts:
- Update user meta using with ajax
- WordPress AJAX Login Screen
- How to link WordPress heartbeat to ajax form
- How to correctly load wordpress in a non WP script for AJAX request
- Confused on AJAX submit form through page template
- Insert wp_editor on front-end with AJAX?
- Help with AJAX front end comment moderation
- Using AJAX with Forms
- Three level taxonomy dropdown frontend
- Performance optimization of tree like structure
- Is it secure to use admin-ajax.php in front?
- Best way to use ajax front-end?
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- wp_ajax declaration confusing for Front end
- Is it possible to determine whether a page is a page template by page_id in ajax call?
- How to get post from pure frontend AJAX (using only post ID)?
- How to make pages that arent indexed for ajax applications
- How to prevent my external API call from being called by anyone but me (my site)
- Update user meta via ajax from frontend, saving issue
- Edit user meta on front-end via AJAX
- How to test if in dashboard, bypassing Ajax quirk
- AJAX Post from same domain to a wordpress page
- retrieving page content per AJAX [duplicate]
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- Is it safe to assume that a nonce may be validated more than once?
- Using Nonces for AJAX that only retrieves data
- How to implement AJAX post navigation into WordPress?
- ajax call in wordpress front end
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- How to make ajax content indexable by search engines?
- Conditional action hooks
- Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?
- How to make get_theme_mod work with AJAX in the customizer preview
- How to check an ajax nonce in PHP
- Fatal error: Call to undefined function get_post() with ajax
- Admin-ajax.php 400 error
- wp_create_nonce() in REST API makes user->ID zero
- Plugin: AJAX query external API to sync to tables
- splitting the URL using jQuery
- How do I get reusable blocks via frontend REST API?
- AJAX Load more on CPT returning random posts
- WordPress admin-ajax.php not available for subscribers/contributors
- WP Ajax never returning any data / calling action
- Should I check for privileges before hooking into `wp_ajax_$handle` or after?
- Refresh Markercluster after ajax call
- How to load content from many posts on a page, only if needed
- Mapping Backbone Models to serialized array in wp_options table
- WordPress Settings api data not sanitized if i use ajax
- Ajax login without redirect/reload
- wp_mail 200 response but no mail sent
- Ajaxify Form That Submits To Same Page To Display Post Data [closed]
- Ajax call with javascript in post content (not enqueued)
- What’s the latest I can hook into wp_ajax_%?
- Nonce doesn’t validate in nopriv call
- Sql formatting for post data within function
- Get returned URL from wp_remote_post if response code is 302
- Change URL without reload Ajax
- Admin-ajax.php 400 error in custom theme
- Why does check_ajax_referer give a 403 error on https websites?
- Hide Load more Ajax button if there is no more users to load or less than the number?
- Send checkbox status with Ajax / JSON and save it
- wp ajax execution time aborted 30 sec
- How to get setting from separate file?
- Contact form – ajax, wp_mail
- WordPress function not defined in AJAX call
- admin-ajax.php calls fail if referrer is sent with 500
- Fetch value using AJAX in WordPress
- AJAX not working when clicking load more button, when two terms are present in tax_query
- AJAX – get_posts for a specific post type returns empty
- Admin Ajax always return 0
- Ajax call undefined index
- WPBakery post content inside Bootstrap Modal
- error_log() not working within wp_ajax_{action} handler
- Is there a way to add ajax hooks without editing the functions.php file?
- check_ajax_reffer not working when logged
- Assign author on ajax wp post insert
- Ajax a php file that has Advanced Custom Fields in it
- AJAX is not submitting data to database
- Display SOLDOUT text in Dropdowns of Variable Product in WooCommerce [closed]
- Code works on page-example.php by not category-example.php
- Using AJAX to load div doesn’t always work
- Turn a URL into content preview
- Deploy Subcategories with Ajax not working
- Allow guest to update custom post met using ajax
- Simulate a specific page when making AJAX calls
- Usage of wp_send_json_success and wp_redirect at the same time
- How to load post_meta for custom post type via Ajax
- Can I make an ajax response cross-domain?
- Static var overwritten with WP AJAX action, works fine without AJAX
- AJAX requests within templates
- using ajax to query sql
- Front-end ajax problem all users and guests getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Use Ajax to get an Options Settings Value