Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Last active March 30, 2023 07:34
Show Gist options
  • Save patrickposner/b28853822eb164d2a4e9999774934224 to your computer and use it in GitHub Desktop.
Save patrickposner/b28853822eb164d2a4e9999774934224 to your computer and use it in GitHub Desktop.
Simply Static: Export all pages with shortcode in Single Export
<?php
add_filter( 'ssp_single_export_additional_urls', function ( $related_urls ) {
global $wpdb;
// Get all pages that have a recent posts shortcode.
$page_ids = $wpdb->get_row( "SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[recent_posts AND post_type='page'", ARRAY_A );
foreach ( $page_ids as $id ) {
$related_urls[] = get_permalink( $id );
return $related_urls;
}
} );
@pixeline
Copy link

It seems to me the return statement should be outside the foreach loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment