Skip to content

Fetch and Organize your Wordpress posts into files and directories!

Notifications You must be signed in to change notification settings

feddynventor/wordpress-bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordPress - BASH

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 .config file 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
        └── 32

data/ folder

This 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

id

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

useful fields

Either one of those is required

  • days which specify the maximum age relative to the current day. The ?after parameter of the REST Api is used.
  • max limits the fetched elements in the submenu. The ?per_page parameter of the REST Api is used.

other fields

  • exclude is useful to fetch the categories specified in id but excluding posts across multiple categories included in this array.
{
    "id": [ 11,12 ],
    "exclude": [ 30 ]
}

API Link

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

TODO

The page management is not implemented, so it's possible to gather maximum 100 posts per category (as explained with the id field)

About

Fetch and Organize your Wordpress posts into files and directories!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages