rtl
11 years ago
class.related-posts-customize.php
1 year ago
jetpack-related-posts.php
1 year ago
readme.md
3 years ago
related-posts-customizer.js
6 years ago
related-posts-rtl.css
1 year ago
related-posts.css
1 year ago
related-posts.js
1 year ago
readme.md
37 lines
| 1 | # Related Posts |
| 2 | |
| 3 | The basic code flow for Related Posts (legacy version) is: |
| 4 | |
| 5 | 1. Generate an empty DIV to be added to the page. |
| 6 | 2. Make an API call to get the working post IDs. |
| 7 | 3. Call `get_related_post_data_for_post()` for each ID. |
| 8 | 4. Use generated data to update the DIV once page load is complete. |
| 9 | |
| 10 | For the block-based version: |
| 11 | |
| 12 | 1. Make an API call to get the working post IDs. |
| 13 | 2. Call `get_related_post_data_for_post()` for each ID. |
| 14 | 3. Use generated data to render the block when called. |
| 15 | |
| 16 | ## Prerequisites |
| 17 | |
| 18 | If using a block theme, the site-wide Related Posts setting will be ignored. For other themes, the site-wide setting is honored as long as a Related Posts block or shortcode is not found on the page. The Related Posts code paths will only output once per page. |
| 19 | |
| 20 | In both cases, the feature needs to be turned on in the Jetpack settings. This makes sense for the legacy widget but can be a bit confusing for the block. It will not be visible in the block "picker" until enabled. |
| 21 | |
| 22 | ## API Usage |
| 23 | |
| 24 | The block depends on wpcom for the working post IDs. See `get_related_post_ids()` for details. The returned data should look like this: |
| 25 | |
| 26 | ``` |
| 27 | [{"id":919},{"id":9},{"id":903}] |
| 28 | ``` |
| 29 | |
| 30 | Note the data used in rendering is all generated locally once the post IDs have been provided. |
| 31 | |
| 32 | ## Block Source |
| 33 | |
| 34 | The source for the Gutenberg block lives separately at: |
| 35 | |
| 36 | `projects/plugins/jetpack/extensions/blocks/related-posts/` |
| 37 |