[Resolved] Include GPP & GBP grid & button styles for CPT elements

Home Forums Support [Resolved] Include GPP & GBP grid & button styles for CPT elements

Home Forums Support Include GPP & GBP grid & button styles for CPT elements

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1638432
    Teresa

    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?

    #1638982
    Peter

    I’ve been wondering the exact same thing. Would be very interested in any replies.

    #1639000
    Peter

    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?

    #1639253
    David
    Staff
    Customer Support

    Hi there,

    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.

    #1639827
    Teresa

    To clarify:

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

    #1640738
    Tom
    Lead Developer
    Lead 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 πŸ™‚

    #1641814
    Teresa

    Great – thanks guys πŸ™‚

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