[Resolved] Get customizer value set for container width

Home Forums Support [Resolved] Get customizer value set for container width

Home Forums Support Get customizer value set for container width

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #788128
    ic7

    Hi there!

    How can I get the value that is set for the container width inside the customizer layout section?
    I need to use the width value in a template file.
    Thanks for your help in advance!

    Best regards
    Sebastian

    #788186
    Leo
    Staff
    Customer Support

    Hi there,

    Not quite sure if I understand.

    The number should show right in the settings:
    https://docs.generatepress.com/article/container-width/

    Is it not for you?

    #788252
    ic7

    Hi Leo, thanks for your reply!

    Yes, the value can be set and is showing in the backend / customizer. What I’m asking is, if there is a function to get this value, which is stored in the database, to be echoed in a template file. Just like the value of a custom field for example.

    #788291
    Leo
    Staff
    Customer Support
    #788638
    ic7

    Thanks Leo, but this doesn’t solve my problem.
    What I need is to get the value of the container width set in the customizer.
    If that value is changed at any time, I need that value to be changed as well in my special template file.
    The value from the customizer gets saved to the database. So I need to retrieve this exact value via a function, so I can use it in a page template.
    Thanks for your help!

    #789140
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this:

    $width = generate_get_option( 'container_width' );

    Let me know 🙂

    #789168
    ic7

    Thanks Tom!
    Exactly what I needed! Works perfect!
    Is there a list of values that can be retrieved from the generate options?

    #789467
    Tom
    Lead Developer
    Lead Developer

    This file might be helpful: https://github.com/tomusborne/generatepress/blob/2.2.1/inc/defaults.php

    Glad I could help!

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