I’m wroking in a DIVI Module that let you choose a metafield to print in the divi layout.

How can I use the id of the post page to filter the metafields used for it?

I try this:

<?php
class DS_Meta_Fields extends ET_Builder_Module{
    ....

    function get_fields(){

        $meta_options = array();
        $meta_fields = get_post_meta($post->ID); 
        foreach($meta_fields as $meta_field => $meta_field_obj) {
            $pt_options[$meta_field] = $meta_field_obj->labels->name;
        }
....

?>

But I don’t obtain the id from the post admin page.

enter image description here

Read more here: Get post id in divi module that works in post.php


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: