Archived topic
Get customizer value set for container width
7 replies · Started by ic7 on January 21, 2019
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
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?
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.
Would Tom's suggestion here helps?
https://generatepress.com/forums/topic/how-to-create-a-page-template-with-a-different-container-width/
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!
Hi there,
Try this:
$width = generate_get_option( 'container_width' );
Let me know :)
Thanks Tom!
Exactly what I needed! Works perfect!
Is there a list of values that can be retrieved from the generate options?
This file might be helpful: https://github.com/tomusborne/generatepress/blob/2.2.1/inc/defaults.php
Glad I could help!