Buffered output in chunks and shortcode – how do I achieve that?

Chunks are irrelevant. Just use output buffering to capture the entire output and then return the result at the end: function buffered_source_to_table( $attrs ) { ob_start(); for($row_values as $r) { echo $r.'<br>’; } return ob_get_clean(); } After ob_start(); any output (from echo, for example) is captured by the output buffer. You then just need to … Read more

How call WordPress shortcode inside function file

I need echo do_shortcode(‘[Shortcode]’); to go where it says “New Item Contents here!” is there any way to do this? Just put it there: add_action( ‘woocommerce_account_new-item_endpoint’, ‘add_new_item_content’ ); /** * Add content to the new tab. * * @return string. */ function add_new_item_content() { echo do_shortcode(‘[Shortcode]’); } Maybe I’m misunderstanding the question, but that’s all … Read more

Custom plugin with shortcode not working

add_shortcode(‘myCustomShortcode’, ‘this_particular_function’); As soon as I looked at my code this morning I realized I was trying to pass the function name ([this_particular_function]) as the shortcode, not the shortcode name ([myCustomShortcode]). I overlooked this SO many times yesterday trying to look for some complex answer! I am smacking my head on the desk. Everything works … Read more

Undefined Function Fatal Error with Shortcode [closed]

Well, the AI didn’t do THAT bad of a job. But either you or the AI didn’t deliver code for the functions get_users_who_commented or get_number_of_comments_by_user which are not wordpress functions but have to be coded seperatly. Also, i would change the code a bit to use wordpress-internal functions like the comment query: function my_custom_shortcode( $atts … Read more

Simple shortcode to check if a user has commented on a certain post

You made 2 small errors. First of all: Shortcode-Functions receive a maximum of 2 parameters: $attributes and $content. $attributes is an array of all the attributes within the shortcode, like [shortcode post_id=123] the attribute post_id will end up in the $attributes array as $attributes[‘post_id’]. $content has the content between the opening and the closing shortcode … Read more