Hi @dragondigitalgroup!
There are multiple ways you can do this, depending on the situation. If your content is stored in a custom post type, you can do this without any custom code:
- Go to the auto-post settings (Post to GMB > Settings > Auto-post settings)
- Enable “Auto-post by default”
- Under “Enabled request type” turn on “Internal”
- In the “Post type settings” tab, enable your custom post type
- Save the settings. The plugin will now automatically publish any newly added content within your CPT.
However, that will simply publish everything, which might not be what you want. You can manually trigger posting for a specific CPT post ID in the following way:
- Make sure your code runs after Post to Google My Business is initialized (which is after the after_setup_theme hook, priority 10)
function pgmb_custom_trigger_autopost() {
global $post_to_google_my_business;
if(!$post_to_google_my_business->is_loaded()){
return;
}
$autopost_factory = $post_to_google_my_business->get_autopost_factory();
if(!$autopost_factory){
return;
}
$autopost_factory->create_autopost($post_id);
}
If you want full manual control over the entire GMB post, you can take a look at the code snippet here. This will let you talk directly to the API and create a custom “LocalPost” object. The code for it is very well documented.
Hope that gets you on your way!