Skip to content

Instantly share code, notes, and snippets.

@brettshumaker
Created March 7, 2017 03:30
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 brettshumaker/ee4a77788d6453ec54bb5f8ce5b8a534 to your computer and use it in GitHub Desktop.
Save brettshumaker/ee4a77788d6453ec54bb5f8ce5b8a534 to your computer and use it in GitHub Desktop.
Simple Staff List change Twitter link
<?php
/**
* Filter to change the Twitter link output
* $output = The HTML for a single staff member inside of the staff loop
* $staff_id = The post ID for the staff member
*/
function gist_sslp_single_loop_markup_filter( $output, $staff_id ) {
// Grab the raw twitter handle from the staff member post
$tw_handle = get_post_meta( $staff_id, '_staff_member_tw', true );
// Replace the custom staff loop tag '[twitter-handle]' with the Staff Member's Twitter handle
$output = str_replace( '[twitter-handle]', $tw_handle, $output );
// Send the filtered output back to the loop
return $output;
}
add_filter( 'sslp_single_loop_markup_filter', 'gist_sslp_single_loop_markup_filter', 10, 2 );
<!--
This is just an example staff loop
To use the custom template tag in functions.php just
copy/paste line 14 below into your own Staff Loop Template
-->
[staff_loop]
<img class="staff-member-photo" src="[staff-photo-url]" alt="[staff-name] : [staff-position]">
<div class="staff-member-info-wrap">
[staff-name-formatted]
[staff-position-formatted]
[staff-bio-formatted]
[staff-email-link]
<!-- This line vvvvvvv -->
<a href="[staff-twitter]" target="_blank">[staff-handle]</a>
<!-- This line ^^^^^^^^ -->
</div>
[/staff_loop]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment