Skip to content

fix: Replace placeholder href with actual sort-by link URL in sort-by dropdown#2776

Merged
Armanul46 merged 1 commit intosovware:developmentfrom
nazmulhasan103:fix/sortby-dropdown-href-link
Apr 5, 2026
Merged

fix: Replace placeholder href with actual sort-by link URL in sort-by dropdown#2776
Armanul46 merged 1 commit intosovware:developmentfrom
nazmulhasan103:fix/sortby-dropdown-href-link

Conversation

@nazmulhasan103
Copy link
Copy Markdown
Member

@nazmulhasan103 nazmulhasan103 commented Apr 1, 2026

Summary

  • Sort-by dropdown <a> tags were using href="#" as a placeholder, relying only on the data-link attribute and JavaScript for navigation
  • Replaced with esc_url( $value['link'] ) so the correct URL is rendered directly in the href attribute
  • The data-link attribute is retained for existing JS-driven behavior (e.g. AJAX filtering)

Why this matters

  • Accessibility: Screen readers and keyboard users expect functional href values on anchor elements
  • SEO: Search engine crawlers follow href links, not data-* attributes — sort options were invisible to crawlers
  • Graceful degradation: Sort links now work even if JavaScript fails or is disabled

Changes

templates/archive/sortby-dropdown.php

- <a href="#" class="..." data-link="<?php echo esc_attr( $value['link'] ); ?>">
+ <a href="<?php echo esc_url( $value['link'] ); ?>" class="..." data-link="<?php echo esc_attr( $value['link'] ); ?>">

Test plan

  • Visit a listing archive page with the sort-by dropdown visible
  • Inspect anchor elements — confirm href now contains the correct sort URL
  • Click each sort option and verify the page sorts correctly
  • Disable JavaScript and verify sort links still navigate to the correct URL
  • Confirm no regression in JS-driven AJAX sort behavior

Sort-by dropdown anchors were using `href="#"` as a placeholder,
relying solely on the `data-link` attribute for navigation. This
replaces the placeholder with the real URL via `esc_url()`, making
the links accessible, crawlable, and functional without JavaScript.
@nazmulhasan103 nazmulhasan103 force-pushed the fix/sortby-dropdown-href-link branch from b8fa476 to 3d7a56a Compare April 1, 2026 06:14
@Armanul46 Armanul46 added this to the 8.6.7 milestone Apr 2, 2026
@Armanul46 Armanul46 merged commit 7596920 into sovware:development Apr 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants