README.md 30.6 KB
Newer Older
Peter J. Herrel's avatar
Peter J. Herrel committed
1
2
3
diggy/polylang-cli
==================

Peter J. Herrel's avatar
Peter J. Herrel committed
4
CLI for the Polylang plugin
Peter J. Herrel's avatar
Peter J. Herrel committed
5
6
7

[![Build Status](https://travis-ci.org/diggy/polylang-cli.svg?branch=master)](https://travis-ci.org/diggy/polylang-cli)

8
Quick links: [Installation](#installation) | [Using](#using) | [Contributing](#contributing) | [Development](#development)
Peter J. Herrel's avatar
Peter J. Herrel committed
9
10
11

## Installation

Peter J. Herrel's avatar
Peter J. Herrel committed
12
Installing this package requires WP-CLI v1.4.0 or greater. Update to the latest stable release with `wp cli update`. 
Peter J. Herrel's avatar
Peter J. Herrel committed
13
Once you've done so, you can install this package with `wp package install [email protected]:diggy/polylang-cli.git`.
Peter J. Herrel's avatar
Peter J. Herrel committed
14
15
16

## Using

Peter J. Herrel's avatar
Peter J. Herrel committed
17
This package implements the following commands:
Peter J. Herrel's avatar
Peter J. Herrel committed
18

Peter J. Herrel's avatar
Peter J. Herrel committed
19
20
### wp pll api

Peter J. Herrel's avatar
Peter J. Herrel committed
21
Inspect Polylang procedural API functions.
Peter J. Herrel's avatar
Peter J. Herrel committed
22
23

~~~
24
wp pll api
Peter J. Herrel's avatar
Peter J. Herrel committed
25
26
27
28
29
30
31
32
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
### wp pll api list

List Polylang procedural API functions.

~~~
wp pll api list [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

**EXAMPLES**

    $ wp pll api list
    $ wp pll api list --format=csv



Peter J. Herrel's avatar
Peter J. Herrel committed
53
54
### wp pll cache

Peter J. Herrel's avatar
Peter J. Herrel committed
55
Inspect and manage Polylang languages cache.
Peter J. Herrel's avatar
Peter J. Herrel committed
56
57

~~~
58
wp pll cache
Peter J. Herrel's avatar
Peter J. Herrel committed
59
60
61
62
63
64
65
66
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
### wp pll cache clear

Clears the Polylang languages cache.

~~~
wp pll cache clear 
~~~

**EXAMPLES**

    $ wp pll cache clear
    Success: Languages cache cleared.

    $ wp pll cache clear --quiet



### wp pll cache get

Gets the Polylang languages cache.

~~~
wp pll cache get [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

**EXAMPLES**

    $ wp pll cache get --format=json
    Success: There are 1 items in the languages cache:
    [{"term_id":2,"name":"Nederlands","slug":"nl","term_group":0,"term_taxonomy_id":2,"taxonomy":"language","description":"nl_NL","parent":0,"count":6259,"tl_term_id":3,"tl_term_taxonomy_id":3,"tl_count":42,"locale":"nl_NL","is_rtl":0,"flag_url":"","flag":"","home_url":"http:\/\/example.dev\/nl\/","search_url":"http:\/\/example.dev\/nl\/","host":null,"mo_id":"3","page_on_front":false,"page_for_posts":false,"filter":"raw","flag_code":""}]

    $ wp pll cache get --format=csv --quiet
    term_id,name,slug,term_group,term_taxonomy_id,taxonomy,description,parent,count,tl_term_id,tl_term_taxonomy_id,tl_count,locale,is_rtl,flag_url,flag,home_url,search_url,host,mo_id,page_on_front,page_for_posts,filter,flag_code
    2,Nederlands,nl,0,2,language,nl_NL,0,10,3,3,42,nl_NL,0,,,http://example.dev/nl/,http://example.dev/nl/,,3,,,raw,



Peter J. Herrel's avatar
Peter J. Herrel committed
109
110
### wp pll doctor

Peter J. Herrel's avatar
Peter J. Herrel committed
111
Troubleshoot Polylang.
Peter J. Herrel's avatar
Peter J. Herrel committed
112
113

~~~
114
wp pll doctor
Peter J. Herrel's avatar
Peter J. Herrel committed
115
116
117
118
119
120
121
122
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
### wp pll doctor check

List untranslated post and term objects (translatable).

~~~
wp pll doctor check [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
		  - json
		  - count
		  - yaml
		---

**EXAMPLES**

    wp pll doctor check



151
152
153
154
155
156
157
158
159
160
161
162
163
164
### wp pll doctor language

Mass install, update and prune core, theme and plugin language files.

~~~
wp pll doctor language 
~~~

**EXAMPLES**

    $ wp pll doctor language



Peter J. Herrel's avatar
Peter J. Herrel committed
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
### wp pll doctor recount

Recalculate number of posts assigned to each language taxonomy term.

~~~
wp pll doctor recount 
~~~

In instances where manual updates are made to the terms assigned to
posts in the database, the number of posts associated with a term
can become out-of-sync with the actual number of posts.

This command runs wp_update_term_count() on the language taxonomy's terms
to bring the count back to the correct value.

**EXAMPLES**

    wp pll doctor recount



### wp pll doctor translate

Peter J. Herrel's avatar
Peter J. Herrel committed
188
Translate untranslated posts and taxonomies in bulk.
Peter J. Herrel's avatar
Peter J. Herrel committed
189
190
191
192
193
194
195
196
197
198
199

~~~
wp pll doctor translate 
~~~

**EXAMPLES**

    wp pll doctor translate



Peter J. Herrel's avatar
Peter J. Herrel committed
200
201
### wp pll flag

Peter J. Herrel's avatar
Peter J. Herrel committed
202
Inspect and manage Polylang country flags.
Peter J. Herrel's avatar
Peter J. Herrel committed
203
204

~~~
205
wp pll flag
Peter J. Herrel's avatar
Peter J. Herrel committed
206
207
208
209
210
211
212
213
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
214
215
### wp pll flag list

Peter J. Herrel's avatar
Peter J. Herrel committed
216
List Polylang country flags.
Peter J. Herrel's avatar
Peter J. Herrel committed
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233

~~~
wp pll flag list [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

**EXAMPLES**

    $ wp pll flag list
    $ wp pll flag list --format=csv



234
235
### wp pll flag set

Peter J. Herrel's avatar
Peter J. Herrel committed
236
Set Polylang country flag for language.
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262

~~~
wp pll flag set <language-code> <flag-code>
~~~

Run `wp pll flag list` to get a list of valid flag values.
Pass an empty string as second parameter to delete the flag value.

**OPTIONS**

	<language-code>
		Language code (slug) for the language to update. Required.

	<flag-code>
		Valid flag code for the language to update. Required.

**EXAMPLES**

    # set flag for Dutch language
    $ wp pll flag set nl nl

    # delete flag for Dutch language
    $ wp pll flag set nl ""



Peter J. Herrel's avatar
Peter J. Herrel committed
263
264
### wp pll lang

Peter J. Herrel's avatar
Peter J. Herrel committed
265
Manage Polylang language taxonomy and taxonomy terms.
Peter J. Herrel's avatar
Peter J. Herrel committed
266
267

~~~
268
wp pll lang
Peter J. Herrel's avatar
Peter J. Herrel committed
269
270
271
272
273
274
275
276
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
### wp pll lang create

Create a language.

~~~
wp pll lang create <name> <language-code> <locale> [--rtl=<bool>] [--order=<int>] [--flag=<string>] [--no_default_cat=<bool>]
~~~

**OPTIONS**

	<name>
		Language name (used only for display). Required.

	<language-code>
		Language code (slug, ideally 2-letters ISO 639-1 language code). Required.

	<locale>
		WordPress locale. Required.

	[--rtl=<bool>]
		Right-to-left or left-to-right. Optional. Default: false

	[--order=<int>]
		Language order. Optional.

	[--flag=<string>]
		Country code, see flags.php. Optional.

	[--no_default_cat=<bool>]
		If set, no default category will be created for this language. Optional.

**EXAMPLES**

    $ wp pll lang create Français fr fr_FR

    $ wp pll lang create Arabic ar ar_AR --rtl=true --order=3

    $ wp pll lang create --prompt
    1/7 <name>: Français
    2/7 <language-code>: fr
    3/7 <locale>: fr_FR
    4/7 [--rtl=<bool>]: 0
    5/7 [--order=<int>]: 5
    6/7 [--flag=<string>]: fr
    7/7 [--no_default_cat=<bool>]:
    Success: Language added.



### wp pll lang delete

328
Delete one, some or all languages.
Peter J. Herrel's avatar
Peter J. Herrel committed
329
330

~~~
331
wp pll lang delete [<language-code>] [--all] [--keep_default]
Peter J. Herrel's avatar
Peter J. Herrel committed
332
333
~~~

334
335
Deletes Polylang languages and uninstalls core language packs if not in use by other languages.

Peter J. Herrel's avatar
Peter J. Herrel committed
336
337
**OPTIONS**

338
339
	[<language-code>]
		Comma-separated slugs of the languages to delete.
Peter J. Herrel's avatar
Peter J. Herrel committed
340

341
342
343
344
345
	[--all]
		Delete all languages

	[--keep_default]
		Whether to keep the default language.
Peter J. Herrel's avatar
Peter J. Herrel committed
346
347
348

**EXAMPLES**

349
350
351
352
    # delete the Afrikaans language and uninstall the `af` WordPress core language pack
    $ wp pll lang delete af
    Success: Language deleted. af (af)
    Success: Language uninstalled.
Peter J. Herrel's avatar
Peter J. Herrel committed
353
354

    # delete all languages including the default language
355
356
357
358
    $ wp pll lang delete --all

    # delete all languages except the default language
    $ wp pll lang delete --all --keep_default
Peter J. Herrel's avatar
Peter J. Herrel committed
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376



### wp pll lang generate

Generate some languages.

~~~
wp pll lang generate [--count=<number>]
~~~

**OPTIONS**

	[--count=<number>]
		How many languages to generate. Default: 10

**EXAMPLES**

Peter J. Herrel's avatar
Peter J. Herrel committed
377
    wp pll lang generate --count=25
Peter J. Herrel's avatar
Peter J. Herrel committed
378
379
380
381
382



### wp pll lang get

Peter J. Herrel's avatar
Peter J. Herrel committed
383
Get a language.
Peter J. Herrel's avatar
Peter J. Herrel committed
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

~~~
wp pll lang get <language-code> [--field=<field>] [--fields=<fields>] [--format=<format>]
~~~

**OPTIONS**

	<language-code>
		ID of the term to get

	[--field=<field>]
		Instead of returning the whole term, returns the value of a single field.

	[--fields=<fields>]
		Limit the output to specific fields. Defaults to all fields.

	[--format=<format>]
		Accepted values: table, json, csv, yaml. Default: table

**EXAMPLES**

Peter J. Herrel's avatar
Peter J. Herrel committed
405
    wp pll lang get en --format=json
Peter J. Herrel's avatar
Peter J. Herrel committed
406
407
408
409
410



### wp pll lang list

411
List installed languages.
Peter J. Herrel's avatar
Peter J. Herrel committed
412
413

~~~
414
wp pll lang list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>] [--pll=<value>]
Peter J. Herrel's avatar
Peter J. Herrel committed
415
416
~~~

417
418
List installed languages as Polylang objects. Passing `--pll=0` will output the result of `wp term list language`

Peter J. Herrel's avatar
Peter J. Herrel committed
419
420
421
422
423
424
425
426
427
428
429
430
431
432
**OPTIONS**

	[--<field>=<value>]
		Filter by one or more fields (see get_terms() $args parameter for a list of fields).

	[--field=<field>]
		Prints the value of a single field for each term.

	[--fields=<fields>]
		Limit the output to specific object fields.

	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
	[--pll=<value>]
		Pass 0 to list languages as WP term objects.

**AVAILABLE FIELDS (POLYLANG OBJECT)**

These fields will be displayed by default for each term:

* term_id
* name
* slug
* term_group
* count
* locale
* is_rtl
* flag_code
Peter J. Herrel's avatar
Peter J. Herrel committed
448
---
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
* term_taxonomy_id
* taxonomy
* description
* parent
* tl_term_id
* tl_term_taxonomy_id
* tl_count
* flag_url
* flag
* home_url
* search_url
* host
* mo_id
* page_on_front
* page_for_posts
* filter

**AVAILABLE FIELDS (WP TERM OBJECT)**
Peter J. Herrel's avatar
Peter J. Herrel committed
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481

These fields will be displayed by default for each term:

* term_id
* term_taxonomy_id
* name
* slug
* description
* parent
* count

There are no optionally available fields.

**EXAMPLES**

482
483
    # list languages as wp term objects
    $ wp pll lang list --pll=0
Peter J. Herrel's avatar
Peter J. Herrel committed
484

485
486
    # list properties of languages as Polylang objects
    $ wp pll lang list --fields=host,mo_id,flag_code
Peter J. Herrel's avatar
Peter J. Herrel committed
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522



### wp pll lang update

Update a language.

~~~
wp pll lang update <language-code> [--name=<name>] [--slug=<slug>] [--locale=<locale>] [--rtl=<bool>] [--order=<int>] [--flag=<string>]
~~~

**OPTIONS**

	<language-code>
		Language code (slug) for the language to update. Required.

	[--name=<name>]
		A new name for the language (used only for display). Optional.

	[--slug=<slug>]
		A new language code for the language (ideally 2-letters ISO 639-1 language code). Optional.

	[--locale=<locale>]
		Optional. A new WordPress locale for the language.

	[--rtl=<bool>]
		Optional. RTL or LTR, 1 or 0

	[--order=<int>]
		Optional. A new order (term_group) value for the language.

	[--flag=<string>]
		Optional. A new flag (country code) for the language, see flags.php.

**EXAMPLES**

Peter J. Herrel's avatar
Peter J. Herrel committed
523
    wp pll lang update en --name=English --order=15
Peter J. Herrel's avatar
Peter J. Herrel committed
524
525
526
527
528



### wp pll lang url

Peter J. Herrel's avatar
Peter J. Herrel committed
529
Get the URL for a language.
Peter J. Herrel's avatar
Peter J. Herrel committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546

~~~
wp pll lang url <language-code>
~~~

**OPTIONS**

	<language-code>
		The language code (slug) to get the URL for. Required.

**EXAMPLES**

    wp pll lang url en
    wp pll lang url es



547
548
549
550
551
### wp pll menu

Manage the WP Nav Menus.

~~~
552
wp pll menu
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
~~~







### wp pll menu create

Create a new menu for each language, AND assign it to a location.

~~~
wp pll menu create <menu-name> <location> [--porcelain]
~~~

**OPTIONS**

	<menu-name>
		A descriptive name for the menu.

	<location>
		Location’s slug.

	[--porcelain]
		Output just the new menu ids.

**EXAMPLES**

    $ wp pll menu create "Primary Menu" primary
    Success: Assigned location to menu.
    Success: Assigned location to menu.
    Success: Assigned location to menu.

    $ wp pll menu create "Secondary Menu" secondary --porcelain
    21 22 23



Peter J. Herrel's avatar
Peter J. Herrel committed
592
593
### wp pll option

Peter J. Herrel's avatar
Peter J. Herrel committed
594
Inspect and manage Polylang settings.
Peter J. Herrel's avatar
Peter J. Herrel committed
595
596

~~~
597
wp pll option
Peter J. Herrel's avatar
Peter J. Herrel committed
598
599
600
601
602
603
604
605
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
606
607
### wp pll option default

Peter J. Herrel's avatar
Peter J. Herrel committed
608
Gets or sets the default language.
Peter J. Herrel's avatar
Peter J. Herrel committed
609
610
611
612
613
614
615
616
617
618
619
620

~~~
wp pll option default [<language-code>]
~~~

**OPTIONS**

	[<language-code>]
		Optional. The language code (slug) to set as default.

**EXAMPLES**

621
622
    $ wp pll option default
    $ wp pll option default nl
Peter J. Herrel's avatar
Peter J. Herrel committed
623
624
625
626
627
628
629
630



### wp pll option get

Get Polylang settings.

~~~
631
wp pll option get <option_name> [--format=<format>]
Peter J. Herrel's avatar
Peter J. Herrel committed
632
633
634
635
636
637
638
~~~

**OPTIONS**

	<option_name>
		Option name. Use the options subcommand to get a list of accepted values. Required.

639
640
641
642
643
644
645
646
647
648
	[--format=<format>]
		Get value in a particular format.
		---
		default: var_export
		options:
		  - var_export
		  - json
		  - yaml
		---

Peter J. Herrel's avatar
Peter J. Herrel committed
649
650
**EXAMPLES**

651
    $ wp pll option get default_lang
Peter J. Herrel's avatar
Peter J. Herrel committed
652
653
654
655
656



### wp pll option list

Peter J. Herrel's avatar
Peter J. Herrel committed
657
List Polylang settings.
Peter J. Herrel's avatar
Peter J. Herrel committed
658
659
660
661
662
663
664
665
666
667
668
669

~~~
wp pll option list [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

**EXAMPLES**

670
671
    $ wp pll option list
    $ wp pll option list --format=csv
Peter J. Herrel's avatar
Peter J. Herrel committed
672
673
674
675
676



### wp pll option reset

Peter J. Herrel's avatar
Peter J. Herrel committed
677
Reset Polylang settings.
Peter J. Herrel's avatar
Peter J. Herrel committed
678
679
680
681
682
683
684

~~~
wp pll option reset 
~~~

**EXAMPLES**

685
    $ wp pll option reset
Peter J. Herrel's avatar
Peter J. Herrel committed
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774



### wp pll option sync

Enable post meta syncing across languages.

~~~
wp pll option sync <item>
~~~

Accepted values:

* taxonomies
* post_meta
* comment_status
* ping_status
* sticky_posts
* post_date
* post_format
* post_parent
* _wp_page_template
* menu_order
* _thumbnail_id

**OPTIONS**

	<item>
		Item, or comma-separated list of items, to sync. Required.

**EXAMPLES**

    $ wp pll option sync taxonomies,post_meta
    Success: Polylang `sync` option updated.



### wp pll option unsync

Disable post meta syncing across languages.

~~~
wp pll option unsync <item>
~~~

Accepted values:

* taxonomies
* post_meta
* comment_status
* ping_status
* sticky_posts
* post_date
* post_format
* post_parent
* _wp_page_template
* menu_order
* _thumbnail_id

**OPTIONS**

	<item>
		Item, or comma-separated list of items, to unsync. Required.

**EXAMPLES**

    $ wp pll option unsync post_format,_wp_page_template
    Success: Polylang `sync` option updated.



### wp pll option update

Update Polylang settings.

~~~
wp pll option update <option_name> <new_value>
~~~

**OPTIONS**

	<option_name>
		Option name. Use the options subcommand to get a list of accepted values. Required.

	<new_value>
		New value for the option. Required.

**EXAMPLES**

775
    $ wp pll option update default_lang nl
Peter J. Herrel's avatar
Peter J. Herrel committed
776
777
778



Peter J. Herrel's avatar
Peter J. Herrel committed
779
780
### wp pll post

781
Manage posts and their translations.
Peter J. Herrel's avatar
Peter J. Herrel committed
782
783

~~~
784
wp pll post
Peter J. Herrel's avatar
Peter J. Herrel committed
785
786
787
788
789
790
791
792
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
793
794
### wp pll post count

Peter J. Herrel's avatar
Peter J. Herrel committed
795
Count posts for a language.
Peter J. Herrel's avatar
Peter J. Herrel committed
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893

~~~
wp pll post count <language-code> [--post_type=<post_type>]
~~~

**OPTIONS**

	<language-code>
		The language code (slug) to get the post count for. Required.

	[--post_type=<post_type>]
		One or more post types to get the count for for. Default: post. Optional.

**EXAMPLES**

    wp pll post count nl
    wp pll post count es --post_type=page



### wp pll post generate

Generate some posts and their translations.

~~~
wp pll post generate [--count=<number>] [--post_type=<type>] [--post_status=<status>] [--post_author=<login>] [--post_date=<yyyy-mm-dd>] [--post_content] [--max_depth=<number>] [--format=<format>]
~~~

Creates a specified number of sets of new posts with dummy data.

**OPTIONS**

	[--count=<number>]
		How many posts to generate?
		---
		default: 5
		---

	[--post_type=<type>]
		The type of the generated posts.
		---
		default: post
		---

	[--post_status=<status>]
		The status of the generated posts.
		---
		default: publish
		---

	[--post_author=<login>]
		The author of the generated posts.
		---
		default:
		---

	[--post_date=<yyyy-mm-dd>]
		The date of the generated posts. Default: current date

	[--post_content]
		If set, the command reads the post_content from STDIN.

	[--max_depth=<number>]
		For hierarchical post types, generate child posts down to a certain depth.
		---
		default: 1
		---

	[--format=<format>]
		Render output in a particular format.
		---
		default: ids
		options:
		  - progress
		  - ids
		---

**EXAMPLES**

    # Generate posts.
    $ wp pll post generate --count=10 --post_type=page --post_date=1999-01-04
    Generating posts  100% [================================================] 0:01 / 0:04

    # Generate posts with fetched content.
    $ curl http://loripsum.net/api/5 | wp pll post generate --post_content --count=10
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2509  100  2509    0     0    616      0  0:00:04  0:00:04 --:--:--   616
    Generating posts  100% [================================================] 0:01 / 0:04

    # Add meta to every generated posts.
    $ wp pll post generate --format=ids | xargs -d ' ' -I % wp post meta add % foo bar
    Success: Added custom field.
    Success: Added custom field.
    Success: Added custom field.



894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
### wp pll post create

Create a new post and its translations.

~~~
wp pll post create --post_type=<type> [--<field>=<value>] [--stdin] [--porcelain]
~~~

**OPTIONS**

	--post_type=<type>
		The type of the new posts. Required.

	[--<field>=<value>]
		Associative args for the new posts. See wp_insert_post(). These values will take precendence over input from STDIN.

	[--stdin]
		Read structured JSON from STDIN.

	[--porcelain]
		Output just the new post ids.

**EXAMPLES**

    # Create a post and duplicate it to all languages
    $ wp pll post create --post_type=page --post_title="Blog" --post_status=publish
    Success: Created and linked 2 posts of the page post type.

    # Create a post and its translations using structured JSON
    $ echo '{"nl":{"post_title":"Dutch title","post_content":"Dutch content"},"de":{"post_title":"German title","post_content":"German content"}}' | wp pll post create --post_type=post --stdin
    Success: Created and linked 2 posts of the post post type.



Peter J. Herrel's avatar
Peter J. Herrel committed
928
929
### wp pll post get

930
List a post and its translations, or get a post for a language.
Peter J. Herrel's avatar
Peter J. Herrel committed
931
932

~~~
Peter J. Herrel's avatar
Peter J. Herrel committed
933
wp pll post get <post_id> [<language-code>] [--api]
Peter J. Herrel's avatar
Peter J. Herrel committed
934
935
936
937
938
939
940
941
~~~

**OPTIONS**

	<post_id>
		Post ID of the post to get. Required.

	[<language-code>]
Peter J. Herrel's avatar
Peter J. Herrel committed
942
943
944
945
		The language code (slug) to get the post ID for, when using the --api flag. Optional.

	[--api]
		Use the Polylang API function pll_get_post()
Peter J. Herrel's avatar
Peter J. Herrel committed
946
947
948

**EXAMPLES**

949
950
    wp pll post get 12
    wp pll post get 1 es --api
Peter J. Herrel's avatar
Peter J. Herrel committed
951
952


953

954
### wp pll post update
955

956
Update one or more existing posts and their translations.
957
958

~~~
959
wp pll post update <id>... [<file>] --<field>=<value> [--defer-term-counting]
960
961
962
963
~~~

**OPTIONS**

964
965
	<id>...
		One or more IDs of posts to update.
966

967
968
969
	[<file>]
		Read post content from <file>. If this value is present, the
		    `--post_content` argument will be ignored.
970

971
972
  Passing `-` as the filename will cause post content to
  be read from STDIN.
973

974
975
	--<field>=<value>
		One or more fields to update. See wp_update_post().
976

977
978
979
980
981
982
983
	[--defer-term-counting]
		Recalculate term count in batch, for a performance boost.

**EXAMPLES**

    $ wp pll post update 13 --comment_status=closed
    Success: Updated post 13.
984
985
986



987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
### wp pll post delete

Delete a post and its translations.

~~~
wp pll post delete <post_id> [--force] [--defer-term-counting]
~~~

**OPTIONS**

	<post_id>
		Post ID of the a translated post to delete. Required.

	[--force]
		Skip the trash bin.

	[--defer-term-counting]
		Recalculate term count in batch, for a performance boost.

**EXAMPLES**

    wp pll post delete 32


Peter J. Herrel's avatar
Peter J. Herrel committed
1011

1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
### wp pll post duplicate

Duplicate a post to one or more languages.

~~~
wp pll post duplicate <post_id> [<language-code>]
~~~

Syncs metadata and taxonomy terms, based on Polylang settings. Run `wp pll option list` to inspect current settings.

**OPTIONS**

	<post_id>
		Post ID of the post to duplicate. Required.

	[<language-code>]
		Language code (slug), or comma-separated list of language codes, to duplicate the post to. Omit to duplicate to all languages. Optional.

**EXAMPLES**

    # Duplicate post 23 (Dutch) to German
    $ wp pll post duplicate 23 de
    Success: Created post 68 (de) < post 23 (nl)

1036
    # Duplicate post 23 (Dutch) to all languages (German and Spanish)
1037
1038
1039
1040
1041
1042
    $ wp pll post duplicate 23
    Success: Updated post 68 (de) < post 23 (nl)
    Success: Created post 69 (es) < post 23 (nl)



Peter J. Herrel's avatar
Peter J. Herrel committed
1043
1044
1045
1046
1047
1048
1049
1050
### wp pll post list

Get a list of posts in a language.

~~~
wp pll post list <language-code> [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
~~~

Peter J. Herrel's avatar
Peter J. Herrel committed
1051
1052
NB: Like Polylang, this command passes a `lang` parameter to WP_Query,
i.e. `wp post list --lang=<language-code>`.
Peter J. Herrel's avatar
Peter J. Herrel committed
1053

Peter J. Herrel's avatar
Peter J. Herrel committed
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
**OPTIONS**

	<language-code>
		The language code (slug) to get the post count for. Required.

	[--<field>=<value>]
		One or more args to pass to WP_Query.

	[--field=<field>]
		Prints the value of a single field for each post.

	[--fields=<fields>]
		Limit the output to specific object fields.

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
		  - ids
		  - json
		  - count
		  - yaml
		---

**AVAILABLE FIELDS**

These fields will be displayed by default for each post:

* ID
* post_title
* post_name
* post_date
* post_status

These fields are optionally available:

* post_author
* post_date_gmt
* post_content
* post_excerpt
* comment_status
* ping_status
* post_password
* to_ping
* pinged
* post_modified
* post_modified_gmt
* post_content_filtered
* post_parent
* guid
* menu_order
* post_type
* post_mime_type
* comment_count
* filter
* url

**EXAMPLES**

    wp pll post list nl

    # List post
    $ wp pll post list es --field=ID
    568
    829
    1329
    1695

    # List posts in JSON
    $ wp pll post list en-gb --post_type=post --posts_per_page=5 --format=json
    [{"ID":1,"post_title":"Hello world!","post_name":"hello-world","post_date":"2015-06-20 09:00:10","post_status":"publish"},{"ID":1178,"post_title":"Markup: HTML Tags and Formatting","post_name":"markup-html-tags-and-formatting","post_date":"2013-01-11 20:22:19","post_status":"draft"}]

    # List all pages
Peter J. Herrel's avatar
Peter J. Herrel committed
1130
    $ wp pll post list nl --post_type=page --fields=post_title,post_status
Peter J. Herrel's avatar
Peter J. Herrel committed
1131
1132
1133
1134
1135
1136
1137
    +-------------+-------------+
    | post_title  | post_status |
    +-------------+-------------+
    | Sample Page | publish     |
    +-------------+-------------+

    # List ids of all pages and posts
Peter J. Herrel's avatar
Peter J. Herrel committed
1138
    $ wp pll post list es --post_type=page,post --format=ids
Peter J. Herrel's avatar
Peter J. Herrel committed
1139
1140
1141
    15 25 34 37 198

    # List given posts
Peter J. Herrel's avatar
Peter J. Herrel committed
1142
    $ wp pll post list nl --post__in=1,3
Peter J. Herrel's avatar
Peter J. Herrel committed
1143
1144
1145
1146
1147
1148
1149
1150
    +----+--------------+-------------+---------------------+-------------+
    | ID | post_title   | post_name   | post_date           | post_status |
    +----+--------------+-------------+---------------------+-------------+
    | 1  | Hello world! | hello-world | 2016-06-01 14:31:12 | publish     |
    +----+--------------+-------------+---------------------+-------------+



Peter J. Herrel's avatar
Peter J. Herrel committed
1151
1152
### wp pll post-type

Peter J. Herrel's avatar
Peter J. Herrel committed
1153
Inspect and manage WordPress post types and their translation status.
Peter J. Herrel's avatar
Peter J. Herrel committed
1154
1155

~~~
1156
wp pll post-type
Peter J. Herrel's avatar
Peter J. Herrel committed
1157
1158
1159
1160
1161
1162
1163
1164
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
### wp pll post-type disable

Disable translation for post types.

~~~
wp pll post-type disable <post_types>
~~~

**OPTIONS**

	<post_types>
		One or a comma-separated list of post types to disable translation for.

**EXAMPLES**

    wp pll post-type disable book



### wp pll post-type enable

Enable translation for post types.

~~~
wp pll post-type enable <post_types>
~~~

**OPTIONS**

	<post_types>
		One or a comma-separated list of post types to enable translation for.

**EXAMPLES**

    wp pll post-type enable book



### wp pll post-type list

List post types with their translation status.

~~~
wp pll post-type list 
~~~

**EXAMPLES**

    wp pll post-type list



1217
1218
1219
1220
1221
### wp pll plugin uninstall

Uninstall Polylang and optionally remove all data.

~~~
1222
wp pll plugin uninstall [--force] [--skip-delete]
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
~~~

**OPTIONS**

	[--force]
		Ignores the Polylang `uninstall` setting and force deletes all data.

	[--skip-delete]
		If set, the plugin files will not be deleted. Only the uninstall procedure
		will be run.

**EXAMPLES**

    $ wp pll uninstall
    $ wp pll uninstall --force
    $ wp pll uninstall --force --skip-delete



1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
### wp pll string

Inspect and manage Polylang string translations.

~~~
wp pll string
~~~







### wp pll string list

List string translations.

~~~
1261
wp pll string list [<language-code>] [--fields=<value>] [--format=<format>] [--s=<value>] [--orderby=<value>] [--order=<value>]
1262
1263
1264
1265
~~~

**OPTIONS**

1266
1267
1268
1269
1270
1271
	[<language-code>]
		The language code (slug) to get the string translations for. Optional.

	[--fields=<value>]
		Limit the output to specific object fields. Valid values are: name, string, context, multiline, translations, row.

1272
1273
1274
	[--format=<format>]
		Accepted values: table, csv, json, count, yaml. Default: table

1275
1276
1277
1278
1279
1280
1281
1282
1283
	[--s=<value>]
		Search for a string in `name` and `string` fields.

	[--orderby=<value>]
		Define which column to sort.

	[--order=<value>]
		Define the order of the results, asc or desc.

1284
1285
**EXAMPLES**

1286
1287
1288
1289
1290
1291
1292
    $ wp pll string list --s="WordPress site"

    $ wp pll string list --order=asc --orderby=string

    $ wp pll string list de --fields=string,translations

    $ wp pll string list es --format=csv
1293
1294
1295



Peter J. Herrel's avatar
Peter J. Herrel committed
1296
1297
### wp pll taxonomy

Peter J. Herrel's avatar
Peter J. Herrel committed
1298
Inspect and manage WordPress taxonomies and their translation status.
Peter J. Herrel's avatar
Peter J. Herrel committed
1299
1300

~~~
1301
wp pll taxonomy
Peter J. Herrel's avatar
Peter J. Herrel committed
1302
1303
1304
1305
1306
1307
1308
1309
~~~







Peter J. Herrel's avatar
Peter J. Herrel committed
1310
1311
### wp pll taxonomy disable

Peter J. Herrel's avatar
Peter J. Herrel committed
1312
Disable translation for taxonomies.
Peter J. Herrel's avatar
Peter J. Herrel committed
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330

~~~
wp pll taxonomy disable <taxonomies>
~~~

**OPTIONS**

	<taxonomies>
		Taxonomy or comma-separated list of taxonomies to disable translation for.

**EXAMPLES**

    wp pll taxonomy disable genre



### wp pll taxonomy enable

Peter J. Herrel's avatar
Peter J. Herrel committed
1331
Enable translation for taxonomies.
Peter J. Herrel's avatar
Peter J. Herrel committed
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345

~~~
wp pll taxonomy enable <taxonomies>
~~~

**OPTIONS**

	<taxonomies>
		Taxonomy or comma-separated list of taxonomies to enable translation for.

**EXAMPLES**

    wp pll taxonomy enable genre

Peter J. Herrel's avatar
Peter J. Herrel committed
1346
1347


Peter J. Herrel's avatar
Peter J. Herrel committed
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
### wp pll taxonomy list

List taxonomies with their translation status.

~~~
wp pll taxonomy list [--format=<format>]
~~~

**OPTIONS**

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
		  - ids
		  - json
		  - count
		  - yaml
		---

**EXAMPLES**

    wp pll taxonomy list



Peter J. Herrel's avatar
Peter J. Herrel committed
1377
1378
### wp pll term

Peter J. Herrel's avatar
Peter J. Herrel committed
1379
Inspect and manage WordPress taxonomy terms and their translations.
Peter J. Herrel's avatar
Peter J. Herrel committed
1380
1381

~~~
1382
wp pll term
Peter J. Herrel's avatar
Peter J. Herrel committed
1383
1384
1385
1386
1387
1388
1389
1390
~~~







1391
### wp pll term get
1392

1393
Get details about a translated term.
1394
1395

~~~
1396
wp pll term get <taxonomy> <term-id> [--field=<field>] [--fields=<fields>] [--format=<format>] [--api]
1397
1398
1399
1400
1401
~~~

**OPTIONS**

	<taxonomy>
1402
		Taxonomy of the term to get
1403

1404
1405
	<term-id>
		ID of the term to get
1406

1407
1408
1409
1410
1411
	[--field=<field>]
		Instead of returning the whole term, returns the value of a single field.

	[--fields=<fields>]
		Limit the output to specific fields. Defaults to all fields.
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
		  - json
		  - yaml
		---

1424
1425
1426
	[--api]
		Use the Polylang API function pll_get_term_translations()

1427
1428
**EXAMPLES**

1429
1430
    # Get details about a category with term ID 18.
    $ wp pll term get category 18
1431
1432
1433



1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
### wp pll term duplicate

Duplicate a taxonomy term to one or more languages.

~~~
wp pll term duplicate <taxonomy> <term-id> [<language-code>]
~~~

**OPTIONS**

	<taxonomy>
		Taxonomy of the term to duplicate

	<term-id>
		ID of the term to duplicate

	[<language-code>]
		Language code (slug), or comma-separated list of language codes, to duplicate the term to. Omit to duplicate to all languages. Optional.

**EXAMPLES**

    # Duplicate term 18 of the category taxonomy to all other languages.
    $ wp pll term duplicate category 18



1460
### wp pll term delete
Peter J. Herrel's avatar
Peter J. Herrel committed
1461

1462
Delete an existing taxonomy term and its translations.
Peter J. Herrel's avatar
Peter J. Herrel committed
1463
1464

~~~
1465
wp pll term delete <taxonomy> <term-id>...
Peter J. Herrel's avatar
Peter J. Herrel committed
1466
1467
~~~

1468
1469
Errors if the term doesn't exist, or there was a problem in deleting it.

Peter J. Herrel's avatar
Peter J. Herrel committed
1470
1471
1472
**OPTIONS**

	<taxonomy>
1473
		Taxonomy of the term to delete.
Peter J. Herrel's avatar
Peter J. Herrel committed
1474

1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
	<term-id>...
		One or more IDs of terms to delete.

**EXAMPLES**

    # Delete a term (English) and its translations (Spanish, French)
    $ wp pll term delete post_tag 56
    Deleted post_tag 56.
    Deleted post_tag 57.
    Deleted post_tag 58.
    Success: Deleted 3 of 3 terms.



### wp pll term list

Get a list of taxonomy terms for a language.

~~~
wp pll term list <taxonomy> <language-code> [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
~~~

**OPTIONS**

	<taxonomy>
		List terms of one or more taxonomies. Required.

	<language-code>
		The language code (slug) to get the taxonomy terms for. Required.

	[--<field>=<value>]
		Filter by one or more fields (see get_terms() $args parameter for a list of fields).
Peter J. Herrel's avatar
Peter J. Herrel committed
1507
1508

	[--field=<field>]
1509
		Prints the value of a single field for each term.
Peter J. Herrel's avatar
Peter J. Herrel committed
1510
1511

	[--fields=<fields>]
1512
		Limit the output to specific object fields.
Peter J. Herrel's avatar
Peter J. Herrel committed
1513
1514
1515
1516
1517
1518
1519
1520

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
1521
		  - ids
Peter J. Herrel's avatar
Peter J. Herrel committed
1522
		  - json
1523
		  - count
Peter J. Herrel's avatar
Peter J. Herrel committed
1524
1525
1526
		  - yaml
		---

1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
**AVAILABLE FIELDS**

These fields will be displayed by default for each term:

* term_id
* term_taxonomy_id
* name
* slug
* description
* parent
* count

These fields are optionally available:

* url
Peter J. Herrel's avatar
Peter J. Herrel committed
1542
1543
1544

**EXAMPLES**

1545
1546
1547
1548
1549
    # List post categories
    $ wp pll term list color nl --format=csv
    term_id,term_taxonomy_id,name,slug,description,parent,count
    2,2,Rood,rood,,0,1
    3,3,Blauw,blauw,,0,1
Peter J. Herrel's avatar
Peter J. Herrel committed
1550

1551
1552
1553
1554
1555
1556
1557
1558
    # List post tags
    $ wp pll term list post_tag en --fields=name,slug
    +-----------+-------------+
    | name      | slug        |
    +-----------+-------------+
    | Articles  | articles    |
    | aside     | aside       |
    +-----------+-------------+
1559
1560
1561



1562
1563
1564
### wp pll term generate

Generate some taxonomy terms and their translations.
1565
1566

~~~
1567
wp pll term generate <taxonomy> [--count=<number>] [--max_depth=<number>] [--format=<format>]
1568
1569
~~~

1570
Creates a specified number of sets of new terms and their translations with dummy data.
1571
1572
1573
1574

**OPTIONS**

	<taxonomy>
1575
		The taxonomy for the generated terms.
1576

1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
	[--count=<number>]
		How many sets of terms to generate?
		---
		default: 5
		---

	[--max_depth=<number>]
		Generate child terms down to a certain depth.
		---
		default: 1
		---

	[--format=<format>]
		Render output in a particular format.
		---
		default: table
		options:
		  - table
		  - csv
		  - json
		  - yaml
		  - ids
		---
1600
1601
1602

**EXAMPLES**

1603
1604
1605
    # Generate some post categories, and translations.
    $ wp pll term generate category --count=3 --format=ids
    115 116 117 118 119 120
1606

Peter J. Herrel's avatar
Peter J. Herrel committed
1607
1608
1609
1610
1611
1612
## Contributing

We appreciate you taking the initiative to contribute to this project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

1613
1614
For a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.

Peter J. Herrel's avatar
Peter J. Herrel committed
1615
1616
1617
1618
1619
1620
### Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should [search existing issues](https://github.com/diggy/polylang-cli/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

1621
Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/diggy/polylang-cli/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).
Peter J. Herrel's avatar
Peter J. Herrel committed
1622
1623
1624
1625
1626

### Creating a pull request

Want to contribute a new feature? Please first [open a new issue](https://github.com/diggy/polylang-cli/issues/new) to discuss whether the feature is a good fit for the project.

1627
Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.
Peter J. Herrel's avatar
Peter J. Herrel committed
1628

1629
1630
1631
1632
1633
## Development

### Behat Tests
To run the Behat tests for polylang-cli, `cd` into the package directory and run `$ ./vendor/bin/behat --expand` from the command line. To run a specific group of tests use the `tags` parameter; e.g.: `$ ./vendor/bin/behat --expand --tags @pll-lang`

Peter J. Herrel's avatar
Peter J. Herrel committed
1634
1635

*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*