Title: Posting programatically
Last modified: July 17, 2025

---

# Posting programatically

 *  [dragondigitalgroup](https://wordpress.org/support/users/dragondigitalgroup/)
 * (@dragondigitalgroup)
 * [11 months, 2 weeks ago](https://wordpress.org/support/topic/posting-programatically/)
 * Hi – the plugin page says there are built in functions but I can’t seem to find
   the documentation on them (apologies if I’ve missed them).
 * I’d like to be able to call a function within WP to post(“text”,”image”,”button”,”
   URL”) or however it might look… is this possible please? I have some custom content
   that I’m just pushing manually now but it’d be great to be able to integrate 
   it into my cron.
 * Thanks for your time

Viewing 1 replies (of 1 total)

 *  Plugin Author [Koen Reus](https://wordpress.org/support/users/koen12344/)
 * (@koen12344)
 * [11 months, 2 weeks ago](https://wordpress.org/support/topic/posting-programatically/#post-18560970)
 * Hi [@dragondigitalgroup](https://wordpress.org/support/users/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:
    1. Go to the auto-post settings (Post to GMB > Settings > Auto-post settings)
    2. Enable “Auto-post by default”
    3. Under “Enabled request type” turn on “Internal”
    4. In the “Post type settings” tab, enable your custom post type
    5. 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:
    1. Make sure your code runs after Post to Google My Business is initialized (which
       is after the after_setup_theme hook, priority 10)
 *     ```wp-block-code
       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](https://gist.github.com/koen12344/63fa57ac1f27292758fdaf6932d951a4).
   This will let you talk directly to the API and create a custom “LocalPost” object.
   The code for it is [very well documented](https://plugins.trac.wordpress.org/browser/post-to-google-my-business/trunk/src/Google/LocalPost.php).
 * Hope that gets you on your way!

Viewing 1 replies (of 1 total)

The topic ‘Posting programatically’ is closed to new replies.

 * ![](https://ps.w.org/post-to-google-my-business/assets/icon-256x256.png?rev=1904100)
 * [Post to Google My Business (Google Business Profile)](https://wordpress.org/plugins/post-to-google-my-business/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-to-google-my-business/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-to-google-my-business/)
 * [Active Topics](https://wordpress.org/support/plugin/post-to-google-my-business/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-to-google-my-business/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-to-google-my-business/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Koen Reus](https://wordpress.org/support/users/koen12344/)
 * Last activity: [11 months, 2 weeks ago](https://wordpress.org/support/topic/posting-programatically/#post-18560970)
 * Status: not resolved