Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 3f8a402

Browse files
authored
remove page by url example with script
1 parent b3a2b06 commit 3f8a402

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

readme.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# How to use it
22
[![License](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://img.shields.io/badge/License-GPL%20v2-blue.svg)
33

4-
## Output structure
4+
## Install
5+
`wp package install codeAtcode/wp-cli-getbyurl`
6+
7+
### Output structure
58
`Kind of content | post id | post type/taxonomy`
69

710
## Commands
@@ -27,4 +30,22 @@ It is a good practice in WP CLI when you have to execute commands that are heavy
2730

2831
### Why the separator is pipe?
2932

30-
In that way is more easy to do script on it in bash or other languages
33+
In that way is more easy to do script on it in bash or other languages
34+
35+
## How to use it
36+
37+
```#!/bin/bash
38+
39+
# How to use the script:
40+
# cat list.txt | xargs -n1 remove-page-by-url.sh
41+
42+
out=`wp get-by-url $1`
43+
command=`cut -d'|' -f1 <<< $out`
44+
id=`cut -d'|' -f2 <<< $out`
45+
taxonomy=`cut -d'|' -f3 <<< $out`
46+
if [ $taxonomy == 'post' ];
47+
wp $command delete $id
48+
else
49+
wp $command delete $taxonomy $id
50+
fi
51+
```

0 commit comments

Comments
 (0)