Permalink Magic Tag
{@permalink}
post_class()
Option 1:
Add post_class_from_id
to Pods Admin > Settings > Display callbacks allowed
and add this callback function as a Code Snippet, plugin, or in theme functions.php:
function post_class_from_id( $id ) {
return implode( ' ', (array) get_post_class( '', $id ) );
}
…then use {@ID,post_class_from_id}
for the Magic Tag.
Option 2:
Add this as a Code Snippet, plugin, or in theme functions.php to add a shortcode:
// Enable shortcodes in Pods templates.
add_filter(
'pods_shortcode',
function( $tags ) {
$tags[ 'shortcodes' ] = true;
return $tags;
}
);
/**
* Add [post_class] shortcode.
* Optional attributes [post_class classes="featured banner" id="123"]
*/
add_shortcode(
'post_class',
function( $atts, $tag, $content ) {
return implode(
' ',
(array) get_post_class(
( array_key_exists( 'classes', $atts ) )
? explode( ' ', $atts['classes'] )
: '',
( array_key_exists( 'id', $atts ) )
? intval( $atts['id'] )
: null
)
);
}
);
…then add define( 'PODS_SHORTCODE_ALLOW_SUB_SHORTCODES', true );
to wp-config.php
and verify Dynamic Features are enabled in Pods Admin > Settings
and Pods Admin > Edit Pods > (The Pod) > Access Rights
The shortcode can then be used as [post_class]
for defaults or [post_class classes="class-one class-two" id="123"]
to add classes or specify a post ID other than global $post
.