Last active
April 26, 2016 21:57
-
-
Save tripflex/f40e1b4a4d70b0df6926 to your computer and use it in GitHub Desktop.
Add additional social media links to Listable WordPress theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Single view Company information box | |
* | |
* Hooked into single_job_listing_start priority 30 | |
* | |
* @since 1.14.0 | |
*/ | |
global $post; | |
// We want to add FaceBook, so we need to set a variable to the value | |
// from the meta key we created. This will be checked below where we output the HTML | |
$facebook_url = get_post_meta( get_the_ID(), '_company_facebook', true); | |
// get our custom meta | |
$location = get_post_meta( get_the_ID(), '_job_location', true); | |
$phone = get_post_meta( get_the_ID(), '_company_phone', true); | |
$twitter = get_post_meta( get_the_ID(), '_company_twitter', true); | |
?> | |
<div class="single-meta"> | |
<?php | |
display_average_listing_rating(); | |
if ( ! empty( $phone ) ) : | |
if ( strlen( $phone ) > 30 ) : ?> | |
<a class="listing-contact listing--phone" href="tel:<?php echo $phone; ?>" itemprop="telephone"><?php esc_html_e( 'Phone', 'listable' ); ?></a> | |
<?php else : ?> | |
<a class="listing-contact listing--phone" href="tel:<?php echo $phone; ?>" itemprop="telephone"><?php echo $phone; ?></a> | |
<?php endif; ?> | |
<?php endif; | |
if ( ! empty( $twitter ) ) { | |
$twitter = preg_replace("[@]", "", $twitter); | |
if ( strlen( $twitter ) > 30 ) : ?> | |
<a class="listing-contact listing--twitter" href="https://twitter.com/<?php echo $twitter; ?>" itemprop="url"> <?php esc_html_e( 'Twitter', 'listable' ); ?></a> | |
<?php else : ?> | |
<a class="listing-contact listing--twitter" href="https://twitter.com/<?php echo $twitter; ?>" itemprop="url">@<?php echo $twitter; ?></a> | |
<?php endif; ?> | |
<?php } | |
// START ADDITIONAL SOCIAL PROFILE (FACEBOOK) | |
if ( ! empty( $facebook_url ) ) { | |
// Listable uses FontAwesome, so check there for any class you need to use | |
// for any additional social media. For facebook, we use icon-facebook. | |
// See here: https://fortawesome.github.io/Font-Awesome/cheatsheet/ | |
// Just replace the "fa-" with "icon-" and it should work | |
?> | |
<a class="listing-contact icon-facebook" href="<?php echo $facebook_url ?>"><?php _e( 'Facebook', 'listable'); ?></a> | |
<?php } | |
// END ADDITIONAL SOCIAL PROFILE (FACEBOOK) | |
if ( $website = get_the_company_website() ) { | |
$website_pure = preg_replace('#^https?://#', '', rtrim(esc_url($website),'/')); | |
if ( strlen( $website_pure ) > 30 ) : ?> | |
<a class="listing-contact listing--website" href="<?php echo esc_url( $website ); ?>" itemprop="url" target="_blank" rel="nofollow"><?php esc_html_e( 'Website', 'listable' ); ?></a> | |
<?php else : ?> | |
<a class="listing-contact listing--website" href="<?php echo esc_url( $website ); ?>" itemprop="url" target="_blank" rel="nofollow"><?php echo $website_pure; ?></a> | |
<?php endif; ?> | |
<?php } ?> | |
</div> |
This is a customized template override file, which you can find more information on the wpjobmanager.com documentation site:
https://wpjobmanager.com/document/template-overrides/
This customized template shows how to add a Facebook field to output next to the Phone, Twitter, and Website links. If you want to add additional fields you need to duplicate setting a variable to the value of the field, then copy and paste between // START ADDITIONAL ..
and // END ADDITIONAL ...
where you want it to show on the site, and update the variable from $facebook_url
to whatever you used as your variable with the value for that field.
There is some documentation in the code itself
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey!
I'm very new to this and need some instructions, where do I put this code into? Do I use Action Hooks?