Last active
August 29, 2015 14:01
-
-
Save tripflex/1b3adfe40e2ad4f41313 to your computer and use it in GitHub Desktop.
Pods Frontend Shortcode to display Custom Post Type for current user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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