admin管理员组文章数量:1122832
This is my first question, please bear with me if I have forgotten any information.
I want to show Divi content (saved as a WordPress project if it's important) inside an overlayed modal. For this I used an AJAX request. Code shown below:
JS
jQuery('.et_pb_portfolio_link').each(function(){
jQuery(this).on("click", function(){
url = jQuery(this).attr('href');
$.ajax({
url : '//page/wp-admin/admin-ajax.php',
data : {
action : 'getOverlayPageContent',
id : 1
},
method : 'POST',
success : function(html) {
jQuery('<div>', {id:'modal', class:'modal'}).appendTo('#main-content');
jQuery('#modal').html(html);
},
error : function(error){ console.log(error) }
})
return false;
});
});
PHP
add_action('wp_ajax_nopriv_getOverlayPageContent', 'getOverlayPageContent');
function getOverlayPageContent() {
// load content
$data = apply_filters('the_content', get_post_field('post_content', 106421));
// Content als JSON zurückgeben
wp_send_json($data);
wp_die();
}
Response (extract)
[et_pb_section fb_built=»1″ fullwidth=»on» _builder_version=»4.24.0″ _module_preset=»default» max_height=»175px» max_height_tablet=»125px» max_height_phone=»100px» max_height_last_edited=»on|tablet» global_colors_info=»{}» theme_builder_area=»post_content»][et_pb_fullwidth_image src=»http://url/wp-content/uploads/2024/02/Screenshot-2024-02-08-121634.png» title_text=»Screenshot 2024-02-08 121634″ module_class=»references_heroimage fw_row» _builder_version=»4.24.0″ _module_preset=»default» global_colors_info=»{}» theme_builder_area=»post_content»][/et_pb_fullwidth_image][/et_pb_section][et_pb_section fb_built=»1″ module_class=»reference_title_section» _builder_version=»4.24.0″ _module_preset=»default» global_colors_info=»{}» theme_builder_area=»post_content»][et_pb_row custom_padding_last_edited=»off|desktop» module_class=»reference_title_row» _builder_version=»4.24.0″ _module_preset=»default» global_colors_info=»{}» theme_builder_area=»post_content»][et_pb_column type=»4_4″ _builder_version=»4.24.0″ _module_preset=»default» global_colors_info=»{}» theme_builder_area=»post_content»][et_pb_text module_class=»reference_title» _builder_version=»4.24.0″ _dynamic_attributes=»content» _module_preset=»default» text_font=»HelveticaNeueLTPro-Hv||» header_2_font=»HelveticaNeueLTPro-Hv||» global_colors_info=»{}» theme_builder_area=»post_content»]@ET-DC@eyJkeW5hbWljIjp0cnVlLCJjb250ZW50IjoicG9zdF90aXRsZSIsInNldHRpbmdzIjp7ImJlZm9yZSI6IiIsImFmdGVyIjoiIn19@[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=»1″ custom_padding_last_edited=»off|tablet» disabled_on=»off|off|off» admin_label=»Image / Text» _builder_version=»4.24.0″ _module_preset=»default» background_enable_color=»off» custom_padding=»0px||0px||false|false» custom_padding_tablet=»150px||150px||false|false»
Post ID 106421 is an example. This is the ID of a matching project page. I get the right content (see above) but it's not rendered through Divi. How can I also process the Divi shortcodes so that I get the full HTML content?
本文标签: phpHow can I display a Divi content inside a modal based on an AJAX request
版权声明:本文标题:php - How can I display a Divi content inside a modal based on an AJAX request 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305621a1932655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论