Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover the html of a post in a rest plugin #676

Open
sudorakrilico opened this issue Feb 22, 2024 · 2 comments
Open

Recover the html of a post in a rest plugin #676

sudorakrilico opened this issue Feb 22, 2024 · 2 comments

Comments

@sudorakrilico
Copy link

Problem Description

I need to be able to recover the rendered html of a post within a function for a rest api, the problem is that it is solved with the divi shortcodes (raw), I try to apply the apply_filter('the_content , $post_content), but it doesn't work , is there any solution?

Regards, and thank you very much.

Steps To Reproduce

I create a rest call to display the html and serve it to another application, but it doesn't render to html.

@hrrarya
Copy link

hrrarya commented Feb 22, 2024

You could explore out et_builder_load_actions filter, If you are trying to retrieve the html from shortcode.

add_filter( 'et_builder_load_actions', function( $builder_load_requests ) {
	$builder_load_requests[] = 'your_ajax_action_here';
	return $builder_load_requests;
}

and in the action callback function, you can fetch et_pb_layout posts by get_posts function , then loop it and call do_shortcode on each post_content. somthing like

$_layouts = get_posts(
        array(
            'post_type'      => 'et_pb_layout',
            'post_status'    => 'publish',
            'posts_per_page' => -1
        )
    );

foreach ($_layouts as $_layout ) {
   do_shortcode($_layout->post_content);
}

let me know the result. all the best man.

@sudorakrilico
Copy link
Author

Thank you very much @hrrarya, I'm sorry for the delay in answering, I haven't been able to solve it with that solution, the call is made within a rest service, the ajax service is not implemented, it has to be rendered from a direct php function.

Greetings and a thousands thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants