Hi @alphawolf, and thanks for your time, really appreciate it.
In the functions.php code you sent me, I’ve replaced the IF test with this:
if (is_integer( get_query_var('year') ) && get_query_var('year') > 0 && get_query_var('year') == $post->post_year ){
to get the currently viewed archive year value. Now, with this code and the new version of the plugin file, the class “current-link” is added in to the <ul><li>
, on every post link listed under the currently viewed year of posts, as you can see in this screenshot. In this case, all <ul></li>
are hidden because I’m not using “Collapsible years” in the plugin options, and each year is linked as I’m using linked years option turned on.
Indeed, what I actually need to do, is to add the class “current” (or “current-link”) to the Year link (see screenshot), not to the listed posts within.
You can see the yearly archive pages I’m talking about here.
If you click on year links, you can see what I got with my change to your plugin.
Specifically, what I did was change line 285 from this
$output .= $before . '<a id="year' . $year . '"></a>' . $linkyears_prepend . $year . $linkyears_append;
to this
$current = (is_integer( get_query_var('year') ) && get_query_var('year') > 0 && get_query_var('year') == $year )?'current':'';
$output .= $before . '<a id="year' . $year . '" class="'.$current.'"></a>' . $linkyears_prepend . $year . $linkyears_append;
So, to sum up it up, I’d need to have a filterable string of classes, added to every <a id="year' . $year . '"></a>
links.
Something like:
$yearclasses = "";
$yearclasses = apply_filters("sya_yearlink", $yearclasses, $year);
$output .= $before . '<a id="year' . $year . '" class="'.$yearclasses.'"></a>' . $linkyears_prepend . $year . $linkyears_append;
Then in my function.php, I can use:
function sya_modify_year_classes( $yearclasses, $year ) {
if (is_integer( get_query_var('year') ) && get_query_var('year') > 0 && get_query_var('year') == $year ){
$classes = explode(" ", $yearclasses);
$classes[] = "current";
$yearclasses = implode( " ", $classes);
}
return $yearclasses;
}
add_filter( 'sya_yearlink', 'sya_modify_year_classes', 10, 3 );
Sorry for the low level of details in my previoius post. Hope the issue is more clear now.
Daniele
-
This reply was modified 2 years, 5 months ago by Mad Max.
-
This reply was modified 2 years, 5 months ago by Mad Max.