I need to display a list of "delete" links for all child posts of a relationship. I'm doing this from within some nested Views.
I tried to create a View that would cycle through all the children, and call the [cred_delete_post_link] shortcode for each one.
This worked in principle, but unfortunately, because my setup is a bit complex, the call to that View was too complex and I couldn't get the View's shortcode to be parsed.
SO - I've written my own shortcode to use instead of that View. This works fine until it comes to actually displaying the delete links.
I mean the only other option I can think of that might work is to use the actual shortcode in your template file by using the do_shortcode function but this itself needs an echo.
Maybe you can construct everything as a large string and just return the entire string of content all at once. Just letting you have some Ideas that i'm thinking.
Since you are doing a loop the return would definitely not work.
You suggested "Maybe you can construct everything as a large string and just return the entire string of content all at once. Just letting you have some Ideas that i'm thinking."
That's exactly what I'm doing, since it seemed like the only option.
I'd not considered including more arguments because the arguments are shown as optional in the documentation. I guess that applies to the shortcode, but not the function.
So, the progress is that the output is now being generated.
The problem now is that it's behaving like echo! All the "Delete this post" links appear at the top of the page rather than within the string I'm trying to construct.
It's a bit of a quirk for such a function - unless there's a reason for it that I haven't figured out.
with $relsArray starting off as an array of the IDs of the posts whose delete links are to be displayed.
The only quirks are:
1. A newline gets displayed before and after the shortcode (annoying but not disastrous), and
2. I still need to figure how to do something sensible after the user clicks. Currently, the link just changes to
"Deleting....." and stays like that. I'll either have to feed in the ID of the current page, and provide that as the redirect page (an optional shortcode attribute), or perhaps do something clever with Ajax.