WPIntell

Source evidence

Highlight current page

Related Links · support · 2014-04-29T13:12:00+00:00

complaintsentiment
mediumseverity
0.75relevance
1replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

2 / 22 rows with source links

9.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

20 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
gemba unresolved
I have related links listed on the left had side of my website which include links to the page you are currently on. I am trying to add a class to the link of the page you are currently on so that I can change the styling. Does anybody know how to do this? https://wordpress.org/plugins/related-links/ I have found the below code in the plugin which I want to change to be something like, if on the current page add a ‘active’ class but all other links on this page not show this class. if ( !function_exists( 'related_links' ) ) { function related_links() { $related_links = get_related_links(); ?> <?php if ( !empty( $related_links ) ) : ?> <ul class="related-links-list"> <?php foreach ( $related_links as $link ): ?> <li><a href="<?php echo $link['url']; ?>"><?php echo $link['title']; ?></a></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php } } ?> I have amended the code to the below, but it shows a class for all links, can anyone help in only showing the class for the link of the page I am currently on if ( !function_exists( 'related_links' ) ) { function related_links() { $related_links = get_related_links(); ?> <?php if ( !empty( $related_links ) ) : ?> <ul class="related-links-list"> <?php foreach ( $related_links as $link ): ?> <li><a href="<?php echo $link['url']; ?>" class="<?php if (is_page( basename(get_permalink()) )) echo 'active'; ?>" ><?php echo $link['title']; ?></a></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php } } ?>

Comments

1 shown
gemba 2014-05-09T13:09:00+00:00

I have found the below code in the plugin which I want to change to be something like, if on the current page add a ‘active’ class but all other links on this page not show this class. if ( !function_exists( 'related_links' ) ) { function related_links() { $related_links = get_related_links(); ?> <?php if ( !empty( $related_links ) ) : ?> <ul class="related-links-list"> <?php foreach ( $related_links as $link ): ?> <li><a href="<?php echo $link['url']; ?>"><?php echo $link['title']; ?></a></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php } } ?> I have amended the code to the below, but it shows a class for all links, can anyone help in only showing the class for the link of the page I am currently on if ( !function_exists( 'related_links' ) ) { function related_links() { $related_links = get_related_links(); ?> <?php if ( !empty( $related_links ) ) : ?> <ul class="related-links-list"> <?php foreach ( $related_links as $link ): ?> <li><a href="<?php echo $link['url']; ?>" class="<?php if (is_page( basename(get_permalink()) )) echo 'active'; ?>" ><?php echo $link['title']; ?></a></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php } } ?>