This is not a Bricks-related article but was born out of the need to show articles with images from sites I wanted to feature. Normally I would use the RSS widget but a combination of reasons made me look for an alternative solution. Not finding the solution I needed, I created a plugin that generates a shortcode.
Why the WP API
As a Bricks user, the lack of native RSS support was the first reason, but if you didn’t know it, nearly 50% of all websites use WordPress meaning that in most cases you can take advantage of the built-in API system to retrieve articles similar to using RSS, but with some huge advantages — primarily speed and content. The API retrieves a JSON package so it is very lightweight even if you request a lot of content. Additionally, unlike RSS, there is almost no limitation to the content you are retrieving.
Plugin Features
By generating a shortcode, the first iteration of my plugin is builder and theme-agnostic. The plugin has one required parameter — the endpoint — and several optional settings.
- Set the number of articles – default is 6
- Set an offset (start at article 5) – default is 0
- Set the heading level (h2-h4) – default is h2
- Set the date format – default is Month Day, Year (F d, Y)
- Choose a category (requires cat ID) – Default is none.
- Choose a post type (requires post type slug) – default is post
- Whether to show category, excerpt, or date – all are visible by default
Working with ChatGPT
I am not a well-seasoned developer, but I know what I want. I turned to ChatGPT to help me with the foundation and the final code review. After about a dozen tweaks of my specifications, the foundation was built. I then set to using the code provided to make additional changes, adding parameters and structure, and then when I was satisfied, I set to test it out. Once I was happy with the results, I requested that ChatGPT review the code and make any security recommendations which it did very quickly. With all the changes in place, I made the repo public. If you are interested, feel free to check out the WP-API-Plugin. This is an as-is plugin.
My use case
You may be asking yourself why would I do this and the answer is simple — work. In my normal job, I oversee several sites using different themes and builders as well as being located in disparate multisite environments. I needed to be able to bring news stories from one site into one or more sites without having to create duplicate posts. The structure of the results should allow you to manipulate the layout in a variety of ways without the need to redo the code — I was able to create the NASA-inspired layout very easily.






