Could you try it like this? The field tags should be uppercased version of the field names.
[loop type="post" count="1" category="legendary" orderby="rand" fields="title, url"]
[ssba title="{TITLE}" url="{URL}"]
[/loop]
The [pass] shortcode is not necessary in this case. Using fields with the loop has the same result.
Thread Starter
flodi
(@flodi)
Not working, now I get an empty url and an empty title.
The ssba shortcode is for this plugin: https://simplesharebuttons.com/wordpress/wordpress-configuration/ and the coded used to get the attributes seems pretty simple:
…
add_shortcode( ‘ssba’, ‘ssba_buttons’ );
…
function ssba_buttons($atts) {
$htmlShareButtons = show_share_buttons(NULL, TRUE, $atts);
return $htmlShareButtons;
}
…
function show_share_buttons($content, $booShortCode = FALSE, $atts = ”) {
…
$urlCurrentPage = (isset($atts[‘url’]) ? $atts[‘url’] : ssba_current_url());
$strPageTitle = (isset($atts[‘title’]) ? $atts[‘title’] : get_the_title());
…
}
Do you see some potential problems?
Oops, I’m sorry, I hadn’t checked my code to see if it works.
Looking deeper, it turns out the parameter fields didn’t take predefined fields into account, only custom fields. I’ll include this in the next update.
Then I found out that tags for predefined fields are enabled by default, even without the fields parameter. I’ll add this point in the documentation so it’s clear.
So, could you try this?
[loop type="post" count="1" category="legendary" orderby="rand"]
[ssba title="{TITLE}" url="{URL}"]
[/loop]
Thread Starter
flodi
(@flodi)
It works!
Thank you
Your plugin is the most useful ever, I use it since the first version, and it saved my butt countless times
Donated for the second time right now, you deserve it.
Wow, thanks, I appreciate it! 🙂
It’s nice to hear that you’ve been using the plugin from the early days. I think at the beginning, all it could do was display a field. So I imagine it’s funny to see how much it’s grown over time. I’m glad you’re finding it useful.
Cheers!
Hello,
I’ve been thinking about these predefined field tags, and I’m planning to make a change to its implementation.
I found out that tags for predefined fields are enabled by default, even without the fields parameter.
I realized that this is not efficient, because it must search for all predefined tags on every loop, even when they’re not used. I want to change the behavior so that only field tags that are specifically defined by the fields parameter will be replaced.
So, if you wouldn’t mind, after downloading the latest version (2.2.4) – could you change the above code to:
[loop type="post" count="1" category="legendary" orderby="rand" fields="title,url"]
[ssba title="{TITLE}" url="{URL}"]
[/loop]
For now, both methods will work, but eventually I plan to make an update so that the fields parameter will be necessary. This will make the loop faster in general.
I hope it won’t be an inconvenience for you!