Skip to content

feat: make rel attribute filterable on company website, Twitter, and apply URL links#2929

Open
masteradhoc wants to merge 6 commits intoAutomattic:trunkfrom
masteradhoc:1497-filter-links
Open

feat: make rel attribute filterable on company website, Twitter, and apply URL links#2929
masteradhoc wants to merge 6 commits intoAutomattic:trunkfrom
masteradhoc:1497-filter-links

Conversation

@masteradhoc
Copy link
Copy Markdown
Contributor

Fixes #1497

Changes Proposed in this Pull Request

  • The rel attribute on the company website link (single job listing view) is now controlled by the job_manager_company_link_rel filter. Default remains nofollow (no behaviour change).
  • The rel attribute on the company Twitter link is now controlled by the same job_manager_company_link_rel filter, with nofollow as the default. Previously this link had no rel attribute.
  • The rel attribute on the apply via URL link is now controlled by a dedicated job_manager_application_url_rel filter. Default remains nofollow (no behaviour change).

Testing Instructions

  1. Visit a single job listing page that has a company website, Twitter handle, and an apply-by-URL set.
  2. Confirm all three links render with rel="nofollow" — identical to previous behaviour.
  3. Add the following to your theme's functions.php and repeat step 2:
// Make company website and Twitter dofollow
add_filter( 'job_manager_company_link_rel', '__return_empty_string' );
  1. Confirm neither the website nor the Twitter link has a rel attribute.

  2. Replace with a type-specific override and repeat:

// Website dofollow, Twitter stays nofollow
add_filter( 'job_manager_company_link_rel', function( $rel, $type ) {
    return 'website' === $type ? '' : $rel;
}, 10, 2 );
  1. Confirm the website link has no rel and the Twitter link retains rel="nofollow".

  2. Test the apply URL filter:

// Apply link dofollow
add_filter( 'job_manager_application_url_rel', '__return_empty_string' );
  1. Confirm the apply link renders without a rel attribute.

  2. Test full security attributes:

add_filter( 'job_manager_company_link_rel', function() {
    return 'nofollow noopener noreferrer';
} );
  1. Confirm all company links render with rel="nofollow noopener noreferrer".

Release Notes

  • Company website, Twitter, and apply URL links now have a filterable rel attribute, allowing site owners to control nofollow/dofollow behaviour without overriding templates.

New or Updated Hooks and Templates

Hook Type Description
job_manager_company_link_rel filter Controls rel on company website and Twitter links. Args: $rel (string), $type ('website'|'twitter'), $post (WP_Post).
job_manager_application_url_rel filter Controls rel on the apply-by-URL link. Args: $rel (string), $apply (object).

Modified templates (child theme overrides of these will need updating):

  • templates/content-single-job_listing-company.php
  • templates/job-application-url.php

Deprecated Code

Screenshot / Video

@azaozz
Copy link
Copy Markdown
Contributor

azaozz commented Mar 25, 2026

Imho these are all good changes. However I'm not an internet marketing specialist, not sure how that may affect existing and future uses (I am aware some people are very sensitive about the rel attributes on links to well known external services). Wondering how can we make sure as many as possible users are aware of these changes before they are released? Is it worth to post about it?

@masteradhoc
Copy link
Copy Markdown
Contributor Author

@azaozz Thanks for your response! There definately could be a post about it though i think the PR offers a consistent default now. The only thing that for sure could be a do follow is the company website but that was already nofollow and is now filterable just in case for those that want to modify it.

@masteradhoc
Copy link
Copy Markdown
Contributor Author

@azaozz @donnchawp i just fixed the merge conflicts here. can we get another review on this one?

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.

Option for NoFollow and Dofollow on Listing Page

2 participants