[Resolved] Custom content in sidebar

Home Forums Support [Resolved] Custom content in sidebar

Home Forums Support Custom content in sidebar

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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!

    #418556
    Leo
    Staff
    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/

    #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.

    #418641
    Tom
    Lead 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.

    #418659
    Alberto

    Hi Tom.
    Thanks for replying!
    I’ll try as you say and I’ll tell you how is going on.

    Regards.

    #419464
    Alberto

    Hi!
    I’d tried as you said and everything seems to be working fine.

    Thanks!

    #419694
    Leo
    Staff
    Customer Support

    Glad we could help!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.