ID placeholder for Custom HTML
-
Hello, I find this plugin amazing and what I’m trying to do is to render a web component either by using a shortcode or directly in custom HTML. The issue that I have is that I need to pass the post ID to the shortcode since using get_the_ID() there returns the ID of the current page, not the ID of the item from the loop.
So in the current version this doesn’t work:add_shortcode( 'isf_story_component', function($attributes) {
$image = wp_get_attachment_url(get_post_thumbnail_id($attributes["id"]));
return '<isf-story image="'.$image.'"></isf-story>';
} );
So to achieve that I added this line inclass-bpfwe-post-widget.php(line 9702).$html_content = str_replace( '#ID#', esc_html( get_the_ID() ), $html_content );So with that I can execute shortcode like this in the post custom HTML:
<div>[isf_story_component id="#ID#"][/isf_story_component]</div>I hope the ID placeholder can be added in the next update. I think it’s a reasonable suggestion since with ID we can do so many things.
You must be logged in to reply to this topic.