So I made a plugin that creates custom post types and widgets with those custom post types. The Custom post type is registered with the init action tag and the widget with the widget_init.
Like so:
public function __construct() {
// load the modules
add_action( 'init', array($this, 'addModule') );
}
public function addModule() {
// register the post type.
register_post_type( $this->post_type, $this->getArgs() );
}
And the widget is called like this:
add_action('widgets_init', function() {
register_widget('Webburo\Widgets\project\ProjectsWidget');
});
When I var_dump()
the post types with get_post_types()
In the widget code, it won't show the newly registered post types. So it seems to me that the post types are no yet registered in the widget_init
. Is there something I'm doing wrong or am I missing something?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire