Wednesday, October 12, 2022
HomeWordPress Developmentcustomized publish varieties - Why does get_page_by_title return null?

customized publish varieties – Why does get_page_by_title return null?


The next operate returns the ID for a given customized publish sort title.

operate get_custom_group_id() {
        $post_type = get_queried_object();
        $group = get_page_by_title( html_entity_decode( $post_type->label ), OBJECT, 'acf-field-group' );
        var_dump($group->ID);
        return $group->ID;
    }

It nonetheless returns a NULL output for the primary few situations like so:

NULL NULL NULL NULL int(413) int(413) int(413) int(413)

I am uncertain why it generates NULL and the way I can clear up it.

Replace

Right here is the operate that calls get_custom_group_id()

operate get_acf_fields() {
    if ( function_exists( 'acf_get_field_groups' ) ) {
        
        $output = acf_get_fields( get_custom_group_id() );
        
        return $output;
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments