0

I've created a custom post type for employee Profiles. The one thing I can't (yet) figure out is how to make custom sidebars for each of the employee's profiles. I have figured out 2 ways to get custom sidebars, but they are not what I want. ( 1.Simple Sidebars plugin; 2.custom code applied to single-profile.php and functions.php) I'm trying to set it up so the site owner doesn't have to go into widgets to edit a sidebar, but rather can edit it within the Profile editor.

I guess what I need to do is 'display custom fields outside the loop'? Then I can use the Advanced Custom Fields plugin to create the fields for the sidebar which will be editable within the editor for the profile CPT. I'm using Genesis.

I'm not referring to metaboxes with dropdowns for sidebar widgets, or sidebar widgets at all, but a way to submit content and a profile image (using Advanced Custom Fields?) within the individual profile editor screen, then a way to output that information individually to the Profile CPT sidebars. Each profile should have a unique sidebar (unique to each employee.) Thanks!!

1

For anyone with the same problem, here's the answer. I finally figured it out.

// Display Profile Sidebar ACF
add_action('genesis_sidebar', 'employee_title');

function profile_photo() {
if ( is_singular('profile') && genesis_get_custom_field('employee_title') )
echo '<div id="employee-title"> '. genesis_get_custom_field('employee_title') .'</div>';
}

This is the the hook location in Genesis where the custom field data needs to output to: genesis_sidebar. Using that puts it in the sidebar. I was using genesis_entry_header which was putting it at the top of the post. I'm putting it in single-profile.php which I created as a template for the custom post type, but you could probably also add it functions.php. Just beware taht you need to replace is_singular('profile') if you are not using a custom post type. Even if you are, replace profile with the name of your custom post type.

As a bonus, there's a div around it for styling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.