- This topic has 7 replies, 4 voices, and was last updated 1 year, 6 months ago by Tom.
January 29, 2021 at 7:36 am #1638432Teresa
I am using GeneratePress Pro and GenerateBlocks, plus a child theme with templates and CPTs to create content arranged in a grid. The specific content I need help with is the Shop page.
I built the site before GBP was released, so while I have added it to the site I have not really utilized its features/functionality for this grid content.
For the sake of consistency, I added GB class names and elements to the code that creates the CPTs. Obviously this only gives me something to hook into and I still need the CSS (plus any other external resources that GB might bring in).
The product grids, button and content are brought in via shortcodes, which obviously does not tell GB to include any of its external or inline resources.
I’m using a hack right now (throwing in a block with a grid and a button & using display:none to hide it).
Is there a better way to tap into GB/GBP styles to make sure we have the same consistent look, and that it’s more futureproof and less of a hack?
Alternatively, or in addition – is there a way to create the CPTs with blocks, or that would trigger inclusion of GB/GBP styles?January 29, 2021 at 8:45 pm #1638982Peter
I’ve been wondering the exact same thing. Would be very interested in any replies.January 29, 2021 at 10:00 pm #1639000Peter
I have used the new global styles feature in GBP on a site and as I use GB for the footer layout the global styles appear to be available on all pages. Therefore I assume they would be available on CPT pages that do not use GB for layout. Is this correct?January 30, 2021 at 5:03 am #1639253DavidStaffCustomer Support
Global Styles in GB Pro should work in this instance – as those styles are output to the GB Styles automatically.
The only thing is we recommend that global styles are used sparingly to stop over bloating the CSS. But if its just a grid and a button block then i see no problem with that.January 30, 2021 at 11:45 am #1639827Teresa
- Are all global styles output into the same style sheet?
- If so, is this style sheet loaded on every page in the site?
- If yes, is this style sheet also the same one loaded by GB if we are using external styles?
I didn’t at all style the grid and button blocks I included in the page. So whatever loads into the page when I include those blocks is, I’m guessing, just default CSS for GB’s button and grid blocks.
So I don’t think I need Global Styles in this instance – I just need the styles I presume are included when those blocks are in the page. Should be mostly or totally layout stuff as (before GBP came out) I wrote my own CSS rather than having to go through and apply styles to every element in the grid. Am I missing something? If my thinking is OK so far then what more do I need to do to get GBP/GPP to include the button and grid CSS on that page? We only need it on this Shop page. I guess I could put only the grid and button elements on some other page, no index/no search that page, then add its style sheet to the page’s header using a hook element. Still kinda hacky though.
Any better ideas?
Edit: It seems Global Styles aren’t just available globally, but do load on every page. I added the button and grid elements with Global Styles, and everything’s now displaying well without the hack.
Still open to better ideas 🙂
Related: Super excited about the projects we’re getting ready to do that can use GBP + Global Styles from the start.January 31, 2021 at 11:20 am #1640738TomLead DeveloperLead Developer
Global Styles will load on any page that has a block from GenerateBlocks. It won’t output any CSS on pages without GenerateBlocks.
If you’re re-using the same styles with the same blocks, then Global Styles are 100% the way to go 🙂February 1, 2021 at 8:48 am #1641814Teresa
Great – thanks guys 🙂February 3, 2021 at 8:48 am #1644447
- You must be logged in to reply to this topic.