While investigating bobbingwide/fizzie/issues/28 I developed a fix for using the [bw_fields] shortcode to display the fields for the current post in an archive display.
If the id attribute value passed to the shortcode is . then the current post ID is used.
This overrides the is_single() checking that I'd implemented 5 years ago.
The code change was to add the last 3 lines in this extract:
function bw_metadata( $atts=null, $content=null, $tag=null ) {
if ( !oik_is_shortcode_expansion_necessary() ) {
return "Not today thank you.";
}
$post_id = bw_array_get( $atts, "id", null );
if ( '.' === $post_id ) {
$post_id = bw_current_post_id();
}
I then found an alternative solution; use [bw_field] instead of [bw_fields].
I could use this because I did not need the field's prefix.
Requirement
Consider adding this as a possible solution to the second @todo for the bw_metadata function
@TODO decide best way to deal with nested usage of this shortcode or multiple usage of this shortcode
* when the post we're trying to process is different from the main post.
* This happens when we are combining information from multiple posts into one output.
* Current solution is to not produce anything, not even 'Not single'
While investigating bobbingwide/fizzie/issues/28 I developed a fix for using the
[bw_fields]shortcode to display the fields for the current post in an archive display.If the
idattribute value passed to the shortcode is.then the current post ID is used.This overrides the
is_single()checking that I'd implemented 5 years ago.The code change was to add the last 3 lines in this extract:
I then found an alternative solution; use [bw_field] instead of [bw_fields].
I could use this because I did not need the field's prefix.
Requirement
Consider adding this as a possible solution to the second @todo for the
bw_metadatafunction