Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/1b3adfe40e2ad4f41313 to your computer and use it in GitHub Desktop.
Save tripflex/1b3adfe40e2ad4f41313 to your computer and use it in GitHub Desktop.
Pods Frontend Shortcode to display Custom Post Type for current user
// Shortcode can be added like this
// [pods_by_current_user_cpt name="document" template="Document Template"]
//
// Supports all shortcode attributes from standard PODS shortcode:
// http://pods.io/docs/learn/shortcodes/pods/
add_shortcode( 'pods_by_current_user_cpt', 'pods_by_current_user_cpt' );
function pods_by_current_user_cpt( $atts, $content = null ) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$atts['where'] = 'post_author = ' . (int) $user_id;
return pods_shortcode( $atts, $content );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment