Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save n7studios/dad3127f020f00a9b4838187f7005511 to your computer and use it in GitHub Desktop.
Save n7studios/dad3127f020f00a9b4838187f7005511 to your computer and use it in GitHub Desktop.
Page Generator Pro: Programmatically Process Spintax
/**
* Make sure to run this after WordPress' init hook has completed.
*/
if ( function_exists( 'Page_Generator_Pro' ) ) {
$spin = Page_Generator_Pro()->get_class( 'spintax' )->process( '{Writing|Creating} {content|articles} is {a lot of fun|rewarding experience}.' );
if ( is_wp_error( $spin ) ) {
// Something went wrong e.g. invalid spintax
// Handle this error as you need
echo $spin->get_error_message();
} else {
// Output spun text
echo $spin;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment