- This topic has 8 replies, 3 voices, and was last updated 1 year, 6 months ago by David.
December 29, 2020 at 7:50 am #1598389Randy
What would be the best way to automate the creation / populating lots of grids on a page.
For example, let’s say there’s a grid for each U.S. State, and it will be populated in a way that there is a consistent filename, title, url etc that can be automated to populate the grid. But I want to leverage a nice looking grid like in GB/GP Premium without having to manually set up all 50 grids on each page where I want to do this.
Suggestions on how to approach that with GB/GP?
Thanks!December 29, 2020 at 8:31 am #1598435DavidStaffCustomer SupportDecember 29, 2020 at 8:31 am #1598436DavidStaffCustomer SupportDecember 29, 2020 at 8:49 am #1598452Randy
It will be just static content in each grid unit, for example an <a href link, an <img src=, and maybe a caption. Very simple static content where the behind the scenes href and img src naming is consistent and so can be automated to populate the grid unit.
Thanks!December 29, 2020 at 9:00 am #1598462DavidStaffCustomer Support
You could create you first grid template, save it as Reusable Block. The reusable block can then be added to new pages, and converted to a regular block so you can update the URLs etc….. but its still very manual, but at least you can set the styling etc for the grid only once.December 29, 2020 at 12:02 pm #1598643Randy
Hmm…I see what you mean. Is there a way to HOOK into a GB (or reusable block) on page load and just repeatedly add the same block, modifying a few things along the way (e.g. url, img src etc)?December 29, 2020 at 10:57 pm #1599040ElvinStaffCustomer Support
If I may suggest:
It may be best to just get a plugin that displays grid loop dynamically from your “US state” instead of trying to create a “bot” for Gutenberg that inserts a Grid Block for each “US state” as this will cost you significant amount of time and development resources with no guarantee of success plus you’re adding more things to worry about because you have to maintain it and make sure it works every time WordPress or the plugin updates.
With what you’re trying to do, the most applicable thing seems to do would be:
1.) Use Pods or CPT to create a custom post type with its proper fields (img, description, state name, population, etc).
2.) Create post for each US state under its own custom post type.
3.) Display these post as a grid with a plugin like WP Show Posts or a custom shortcode that specifically renders a grid loop.
4.) Modify how it looks with CSS.
While I completely understand why you want to do this(GB is great for styling), Gutenberg editor, or GenerateBlocks, isn’t created for this kind of process.
A wise man once said:
"Have you cleared your cache?"December 30, 2020 at 6:33 am #1599392Randy
Some interesting thoughts Elvin, thank you. I’d really rather not add more plugins to the site…I’d rather keep it lightweight if at all possible.
It seems that your Block Element with Hooks is very close to what I need, if I were able to add a loop to repeatedly add a Block Element to the page content (e.g. one for each state), just using php str_replace to replace the content in each Block Element as it’s added in a loop.
That would be awesome to be able to do that with GP/GB Block hooks.December 30, 2020 at 7:01 am #1599603DavidStaffCustomer Support
This really sounds like the best solution is what Elvin offered.
You may just want to create a CPT and a custom Archive template. Then those ‘pages’ will be automatically generated.
If you need to add the post grids to a static page then the WP Show Posts plugin is the way to go.
We have some plans for dealing with dynamic data in GPP and GB in the future, and WPSP will also get ‘blockified’. But until then the method above is the way to go – and even when that does occur you will still need a CPT for this kind of functionality.
- You must be logged in to reply to this topic.