I'm trying to group items after heading like in this post.
https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/
So I have edited the function and the shortcode, but alas it will not work
//group by title
add_shortcode('heading', 'my_heading');
function my_heading($atts, $content = '') {
static $title = null;
static $month = null;
$condition = $atts['condition'];
$value = $atts['value'];
switch ($condition) {
case 'title':
case 'month':
if ($$condition != $value) {
$$condition = $value;
return $content;
}
break;
}
return '';
}
[heading condition="title" value="[wpv-post-title]"][heading]
Thanks
Hi Cedric,
Thank you for waiting.
I've checked your view ( "Home page Christophe Deval ACT" ) and noticed that custom shortcode "heading" seems to be working now.
Without the shortcode:
hidden link
With the shortcode:
hidden link
Looks like you've managed to make it work after writing to us - well done.
Please let me know if you still need any assistance around this.
regards,
Waqar
Hi,
In fact, it was like a theorical issue.
I manage to make it work, passing the post-title in the variable year (with the documentation example code),
but it's not really durable if someone get over the project after me 😉 He will understand nothing or will name me with words I can't ear 😉
Thanks,
Cédric
Hi Cédric,
Thanks for sharing the update.
An alternative to this approach can be custom JavaScript/jQuery or CSS code that hides the duplicate headings, but it can be equally difficult to implement or maintain. For this reason, I'll recommend to keep using the current shortcode method.
To make the purpose/role of the custom "heading" shortcode clear for someone who'll work on the project after you, you can include some comment notes along with the link to the source post ( https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/ ) in the code where this shortcode is defined.
regards,
Waqar
My issue is resolved now. Thank you!