Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve [bw_fields] to use within a core/query-loop block #34

Open
bobbingwide opened this issue Nov 10, 2020 · 0 comments
Open

Improve [bw_fields] to use within a core/query-loop block #34

bobbingwide opened this issue Nov 10, 2020 · 0 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant