Home › Forums › Support › Custom content in sidebar This topic has 6 replies, 3 voices, and was last updated 7 years, 1 month ago by Leo. Viewing 7 posts - 1 through 7 (of 7 total) Author Posts November 8, 2017 at 5:42 am #418370 Alberto Hello. I’m looking for the way to add custom fields to the left sidebar only in certain pages, so I think using conditionals like this may works: <?php if ( get_post_type( get_the_ID() ) == 'my_cpt' && is_singular() && is_active_sidebar( 'left-sidebar' ) ) { ?> //Here goes the custom fields <?php } ?> If this is the right way, where must I place this code (any hook?)? BTW, My custom fields are ACF ones. Thanks in advance! November 8, 2017 at 8:40 am #418556 LeoStaff Customer Support Hi there, I think using sidebar widgets would be a better choice? Then yo can use this plugin so that it only displays on certain pages: https://en-ca.wordpress.org/plugins/content-aware-sidebars/ November 8, 2017 at 8:57 am #418584 Alberto Hi Leo. The problem is not displaying the sidebar on certain pages but displaying my custom fields (added with Advanced Custom Fields) Is it possible with that plugin?, is not possible without using a plugin? Regards. November 8, 2017 at 10:11 am #418641 TomLead Developer Lead Developer You could put your custom field into shortcodes: https://codex.wordpress.org/Shortcode_API Then use the plugin Leo mentioned to show/hide text widgets with your shortcodes in them. Widgets don’t accept PHP, so you’d have to go the shortcode route. November 8, 2017 at 10:39 am #418659 Alberto Hi Tom. Thanks for replying! I’ll try as you say and I’ll tell you how is going on. Regards. November 9, 2017 at 5:56 am #419464 Alberto Hi! I’d tried as you said and everything seems to be working fine. Thanks! November 9, 2017 at 8:39 am #419694 LeoStaff Customer Support Glad we could help! Author Posts Viewing 7 posts - 1 through 7 (of 7 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In