This is a small shortcode to display an isometric view of images from the latest REST endpoint images.
-
- 2.1. Built With
- 2.2. Installation
-
- 3.1.
[andyp_rest_isometric]
- 3.2.
[andyp_isometric_rest]
- 3.1.
This wordpress plugin was created to pull in the latest images from ParkourLabs.com into LondonParkour.com so that a nice "isometric" CSS-effect of images could be displayed to show the latest tutorial posts. To accomplish this, two parts needs to happen:
- ParkourLabs needed to extend it's REST API so that the custom post type and associated images could be queried.
- LondonParkour needed a shortcode to communicate with that REST API endpoint, pull the images and render them out in the "isometric" grid.
This plugin concentrates on the second part. It communicates with the API and pulls data.
This project was built with the following frameworks, technologies and software.
These are the steps to get up and running with this plugin.
- Clone the repo into your wordpress plugin folder
git clone https://github.com/IORoot/wp-plugin__rest--isometric ./wp-content/plugins/ParkourLabs_REST_API_isometric
- Insert one of the two shortcodes into your page.
[andyp_rest_isometric] or [andyp_isometric_rest]
There are two shortcodes available:
The [andyp_rest_isometric]
shortcode can be used to automatically query the ParkourLabs.com REST API and render the image isometric grid.
Just place wherever needed in your page.
This has a couple of features worth noting:
- It uses transients of one day. This is to cache the results.
- It styles the output based on the TailwindCSS Framework.
This shortcode allows for much more flexibility. There are six parameters that can be used to control the output.
- The number of results you wish to retrieve. Default is 5.
[andyp_isometric_rest count="10"]
- The column of data to order the results. Default is "date"
[andyp_isometric_rest order="date"]
- The posttype to actually search upon. The default is "tutorial".
[andyp_isometric_rest posttype="post"]
- The category name to filter the results upon. The default is null.
[andyp_isometric_rest category="demos"]
- The classes you wish to add to the resulting images. The default is empty.
[andyp_isometric_rest classes="w-10 block rounded"]
6 The content
is anything that's between and opening and close tag. This allows for {{moustache}}
brackets to substitute any post column to substituted for its value:
[andyp_isometric_rest]
This is the title: {{post_title}}
[/andyp_isometric_rest]
Using this shortcode allows you return multiple posts and display their details: e.g.
[andyp_isometric_rest posttype="post" count="10" classes="w-10 rounded p-4 bg-gray-500"]
<h1>{{post_title}} : {{published_date}}</h1>
[/andyp_isometric_rest]
You can simply change the endpoint in the code here:
https://github.com/IORoot/wp-plugin__REST--labs/blob/master/src/REST/labs_rest.php
Line 20:
public $endpoint = "https://parkourlabs.com/wp-json/wp/v2";
https://github.com/IORoot/wp-plugin__REST--labs/blob/master/src/REST/labs.php Line 14
public $endpoint = "https://parkourlabs.com/wp-json/wp/v2";
If the site is not picking up the JSON and images delete the transients using the WP CLI tool.
sudo -u www-data wp transient list
sudo -u www-data wp transient delete labsrest-blog
sudo -u www-data wp transient delete labsrest-demonstration
sudo -u www-data wp transient delete labsrest-tutorial
sudo -u www-data wp transient delete labsstack
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue. Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.
MIT License
Copyright (c) 2022 Andy Pearson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Author Link: https://github.com/IORoot
v1.0.0 - initial version