Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created May 24, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/d6590ed91d58a415198d7ea6e0352890 to your computer and use it in GitHub Desktop.
Save tripflex/d6590ed91d58a415198d7ea6e0352890 to your computer and use it in GitHub Desktop.
Custom PHP code to generate a custom link from WP Job Manager Field Editor field, with the field value in query args for the link
<?php
$candidate_name = get_custom_field( 'candidate_name' );
if ( ! empty( $candidate_name ) ) {
$some_url = 'http://somedomain.com/';
$search_url = add_query_arg(
array(
'candidate_name' => $candidate_name,
),
$some_url
);
// If the value from candidate_name was 'John', the code above essentially creates this URL:
// http://somedomain.com/?candidate_name=John
echo "<a class=\"some-custom-class\" href=\"{$some_url}\" target=\"_blank\">Some Link</a>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment