Skip to content

Instantly share code, notes, and snippets.

@tomatillodesign
Last active November 6, 2018 17:56
Show Gist options
  • Save tomatillodesign/1771dcf4d717551b2beeddd47b1abb8d to your computer and use it in GitHub Desktop.
Save tomatillodesign/1771dcf4d717551b2beeddd47b1abb8d to your computer and use it in GitHub Desktop.
WP Template Work
<?php
/* Alex, here is your challenge:
1) Save this file and upload it to wp-content/themes/corporate-pro
You will want your code here to only apply to single sites. Use https://wphierarchy.com to determine the filename that you should use. It will be one of these:
a) single.php
b) page-sites.php
c) single-sites.php
d) sites-single.php
e) singular-sites.php
2) Write a function that will add new content to the top of genesis_entry_content. Make sure you get and display the custom fields that we added
Here are the fields you'll need to include:
site_contact_email
site_phone_number
site_hours
site_link
Please wrap everything in #2 here inside a div with the class of "site-info-area"
3) Bonus: use conditional if statements to make sure that an empty field will not be displayed
if( $variable_name ) { echo 'TEST'; }
Just let me know if you have questions!
*/
add_action('genesis_hook_here', 'arod_display_site_info', 10); // change the genesis hook; change the number to display up above the entry content (ie should be lower than 10)
function arod_display_site_info() {
echo '<h2>TEST - is the function working?</h2>';
$variable_name = get_field('field_name'); // copy as necessary to get all the fields displayed
echo '<div class="site-info-area">' . $variable_name . '</div>'; // copy as necessary to get all the fields displayed
}
// don't forget to add the missing genesis(); function, or else this won't work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment