This tool maps any WordPress website to your predefined tree structure
As everything is a file, a tree of files is ideal to store your content in a pretty organized way. Thanks file system =D
Each subdirectory can contain:
- a
.configfile which specifies a list of WordPress category IDs, plus other directives - other subdirectories
- both
data
├── 7
├── 1_Genres
│ ├── 11
│ ├── 12
│ └── 13
├── 2_Sport
│ ├── 20
│ └── 1_Highlights
│ └── 21
└── 3_Talkshows
├── 1_Talk A
│ └── 83
└── 2_Talk C
├── 12
└── 32This is the root of your submenus structure. So start making some directories!
Make sure to name them starting with the prefix N_. This will guarantee your sorting order, achieved with a simple sort on a simple find output.
Where you want your items to be, place a .config
configs are written in JSON as it is easily human readable
The mandatory field is id and it's an array of category IDs
{
"id": [
11,
12,
{ "id": 13, "name": "Fantasy" }
]
}
The script fetches one time per each specified ID, saving the corresponding JSON.
This is done in order to virtually multiply the per_page limit
Whether the name field is specified, a main_category field is added to the post entity.
This leaves the WordPress categories field untouch for further usage
Either one of those is required
dayswhich specify the maximum age relative to the current day. The?afterparameter of the REST Api is used.maxlimits the fetched elements in the submenu. The?per_pageparameter of the REST Api is used.
excludeis useful to fetch the categories specified inidbut excluding posts across multiple categories included in this array.
{
"id": [ 11,12 ],
"exclude": [ 30 ]
}
DOMAIN= DAYS= LIMIT= wget \ $DOMAIN/wp-json/wp/v2/posts\ \ ?_fields\=id,date,modified,title,categories,acf,featured_media \ &after\="$(date --date '$DAYS days ago' --iso-8601)"T00:00:00 \ &per_page=${LIMIT} \ &page=1 \ | jq
The page management is not implemented, so it's possible to gather maximum 100 posts per category (as explained with the id field)