Python WordPress¶
A Python library for interacting with WordPress REST API.
- Free software: MIT License
Features¶
- TODO
Quick Start¶
>>> from wordpress import WordPress
>>> wp = WordPress('http://example.org/')
>>> posts = wp.list_posts()
>>> for p in posts:
... print('{title[rendered]}: {link}'.format(**p._json))
Hello, World: http://example.org/2017/01/30/hello-world
Contents:¶
Installation¶
Stable release¶
To install Python WordPress, run this command in your terminal:
$ pip install python-wp
This is the preferred method to install Python WordPress, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for Python WordPress can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/myles/python-wp
Or download the tarball:
$ curl -OL https://github.com/myles/python-wp/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage¶
To use Python WordPress in a project:
from wordpress import WordPress
wp = WordPress('http://wordpress-site.dev/')
Get a list of posts:
wp.list_posts()
Retrieve a post:
wp.get_post(443)
Delete a post:
wp.delete_post(443)
wordpress¶
wordpress package¶
Submodules¶
wordpress.api module¶
-
class
wordpress.api.
WordPress
(url, verify_ssl=True)[source]¶ Bases:
object
-
create_post
(date=None, date_gmt=None, slug=None, status=None, password=None, title=None, content=None, author=None, excerpt=None, featured_media=None, comment_status=None, ping_status=None, format=None, meta=None, sticky=None, template=None, categories=None, tags=None, liveblog_links=None)[source]¶ Create a Post.
Parameters: - date (datetime) – The date the object was published, in the site’s timezone.
- date_gmt (datetime) – The date the object was published, as GMT.
- slug (str) – An alphanumeric identifier for the object unique to its type.
- status (str) –
A named status for the object.
One of: publish, future, draft, pending, private
- password (str) – A password to protect access to the content and excerpt.
- title (str) – The title for the object.
- content (str) – The content for the object.
- author (id) – The ID for the author of the object.
- excerpt (str) – The excerpt for the object.
- featured_media (int) – The ID of the featured media for the object.
- comment_status (str) –
Whether or not comments are open on the object.
One of: open, closed
- ping_status (str) –
Whether or not the object can be pinged.
One of: open, closed
- format (str) –
The format for the object.
One of: standard
- meta (dict) – Meta fields.
- sticky (bool) – Whether or not the object should be treated as sticky.
- template (str) –
The theme file to use to display the object.
One of:
- categories (str) – The terms assigned to the object in the category taxonomy.
- tags (str) – The terms assigned to the object in the post_tag taxonomy.
- liveblog_likes (str) – The number of Liveblog Likes the post has.
-
delete_post
(pk, force=False)[source]¶ Delete a Post.
Parameters: - pk (int) – The post id you want to delete.
- force (bool) – Whether to bypass trash and force deletion.
-
delete_post_revision
(parent, pk)[source]¶ Delete Post Revision.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- pk (int) – Unique identifier for the object.
Returns: Return type: dict
-
get_category
(pk, context='view')[source]¶ Retrieve a Category.
Parameters: - pk (int) – The category id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
get_post
(pk, context='view', password=None)[source]¶ Retrieve a Post.
Parameters: - pk (in) – The post id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- password (str) – The password for the post if it is password protected.
Returns: Return type:
-
get_post_revision
(parent, pk, context='view')[source]¶ Get a Post Revision.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- pk (int) – Unique identifier for the object.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view
Returns: Return type:
-
get_post_status
(slug, context='view')[source]¶ Retrieve a Post statuses
Parameters: - slug (str) – The name of the status.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
get_tag
(pk, context='view')[source]¶ Retrieve a Tag.
Parameters: - pk (int) – The tag id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
list_categories
(context='view', page=1, pre_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None)[source]¶ Get a list of categories.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) –
Current page of the collection.
Default: 1
- pre_page (int) –
Maximum number of items to be returned in result set.
Default: 10
- search (str) – Limit results to those matching a string.
- exclude (int) –
Ensure result set excludes specific IDs.
Default:
- include (int) –
Limit result set to specific IDs.
Default:
- order (str) –
Order sort attribute ascending or descending.
Default: asc
One of: asc, desc
- orderby (str) –
Sort collection by term attribute.
Default: name
One of: id, include, name, slug, term_group, description, count
- hide_empty (bool) – Whether to hide terms not assigned to any posts.
- parent (int/wordpress.models.Category) – Limit result set to terms assigned to a specific parent.
- post (int/wordpress.models.Post) – Limit result set to terms assigned to a specific post.
- slug (str) – Limit result set to terms with a specific slug.
Returns: A list of wordpress.models.Category.
Return type: list
- context (str) –
-
list_post_revisions
(parent, context='view')[source]¶ List Post Revisions.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view
Returns: A list of wordpress.models.PostRevision.
Return type: list
-
list_post_statuses
(context='view')[source]¶ Get a list of post statuses.
Parameters: context (str) – Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: A list of wordpress.models.PostStatus Return type: list
-
list_posts
(context='view', page=1, pre_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', categories=None, cateogries_exclude=None, tags=None, tags_exclude=None, sticky=None)[source]¶ Get a list of posts.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) – Current page of the collection.
- pre_page (int) – Maximum number of items to be returned in result set.
- search (str) – Limit results to those matching a string.
- after (datetime) – Limit response to posts published after a given date.
- author (int) – Limit result set to posts assigned to specific authors.
- author_exclude (int) – Ensure result set excludes posts assigned to specific authors.
- before (datetime) – Limit response to posts published before a given date.
- exclude (int) – Ensure result set excludes specific IDs.
- include (int) – Limit result set to specific IDs.
- offset (int) – Offset the result set by a specific number of items.
- order (str) –
Order sort attribute ascending or descending.
Default: desc
One of: asc, desc
- orderby (str) – Sort collection by object attribute. Default: date One of: date, relevance, id, include, title, slug
- slug (str) – Limit result set to posts with one or more specific slugs.
- status (str) –
Limit result set to posts assigned one or more statuses.
Default: publish
One of: publish, future, draft, pending, private
- categories (str) – Limit result set to all items that have the specified term assigned in the categories taxonomy.
- categories_exclude (str) – Limit result set to all items except those that have the specified term assigned in the categories taxonomy.
- tags (str) – Limit result set to all items that have the specified term assigned in the tags taxonomy.
- tags_exclude (str) – Limit result set to all items except those that have the specified term assigned in the tags taxonomy.
- sticky (bool) – Limit result set to items that are sticky.
Returns: A list of wordpress.models.Post.
Return type: list
- context (str) –
Get a list of tags.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) –
Current page of the collection.
Default: 1
- per_page (int) –
Maximum number of items to be returned in result set.
Default: 10
- search (str) – Limit results to those matching a string.
- exclude (str) –
Ensure result set excludes specific IDs.
Default:
- include (list) –
Limit result set to specific IDs.
Default:
- offset (int) – Offset the result set by a specific number of items.
- order (str) –
Order sort attribute ascending or descending.
Default: asc
One of: asc, desc
- orderby (str) –
Sort collection by term attribute.
Default: name
One of: id, include, name, slug, term_group, description, count
- hide_empty (bool) – Whether to hide terms not assigned to any posts.
- post (int) – Limit result set to terms assigned to a specific post.
- slug (str) – Limit result set to terms with a specific slug.
Returns: A list of wordpress.models.Category.
Return type: list
- context (str) –
-
update_post
(pk, date=None, date_gmt=None, slug=None, status=None, password=None, title=None, content=None, author=None, excerpt=None, featured_media=None, comment_status=None, ping_status=None, format=None, meta=None, sticky=None, template=None, categories=None, tags=None, liveblog_links=None)[source]¶ Update a Post.
Parameters: - pk (int) – The ID of the post you want to update.
- date (datetime) – The date the object was published, in the site’s timezone.
- date_gmt (datetime) – The date the object was published, as GMT.
- slug (str) – An alphanumeric identifier for the object unique to its type.
- status (str) –
A named status for the object.
One of: publish, future, draft, pending, private
- password (str) – A password to protect access to the content and excerpt.
- title (str) – The title for the object.
- content (str) – The content for the object.
- author (id) – The ID for the author of the object.
- excerpt (str) – The excerpt for the object.
- featured_media (int) – The ID of the featured media for the object.
- comment_status (str) –
Whether or not comments are open on the object.
One of: open, closed
- ping_status (str) –
Whether or not the object can be pinged.
One of: open, closed
- format (str) –
The format for the object.
One of: standard
- meta (dict) – Meta fields.
- sticky (bool) – Whether or not the object should be treated as sticky.
- template (str) –
The theme file to use to display the object.
One of:
- categories (str) – The terms assigned to the object in the category taxonomy.
- tags (str) – The terms assigned to the object in the post_tag taxonomy.
- liveblog_likes (str) – The number of Liveblog Likes the post has.
-
update_setting
(title=None, description=None, url=None, email=None, timezone=None, date_format=None, time_format=None, start_of_week=None, language=None, use_smilies=None, default_category=None, default_post_format=None, post_pre_page=None)[source]¶ Update WordPress settings.
Parameters: - title (str) – Site title.
- description (str) – Site description.
- url (str) – Site URL.
- email (str) – This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. The new address will not become active until confirmed.
- timezone (str) – A city in the same timezone as you.
- date_format (str) – A date format for all date strings.
- time_format (str) – A time format for all time strings.
- start_of_week (int) – A day number of the week that the week should start on.
- language (str) – WordPress locale code.
- use_smilies (bool) – Convert emoticons like :-) and :-P to graphics on display.
- default_category (int) – Default category.
- default_post_format (str) – Default post format.
- posts_per_page (int) – Blog pages show at most.
-
wordpress.models module¶
Copyright 2009-2010 Joshua Roesslein
-
class
wordpress.models.
Category
(api=None)[source]¶ Bases:
wordpress.models.Model
A WordPress Category
Parameters: - id (int) –
Unique identifier for the term.
Context: view, embed, edit
- count (int) –
Number of published posts for the term.
Context: view, edit
- description (str) –
HTML description of the term.
Context: view, edit
- link (str) –
URL of the term.
Context: view, embed, edit
- name (str) –
HTML title for the term.
Context: view, embed, edit
- slug (str) –
An alphanumeric identifier for the term unique to its type.
Context: view, embed, edit
- taxonomy (str) –
Type attribution for the term.
Context: view, embed, edit
One of: category, post_tag, nav_menu, link_category, post_format
- parent (int) –
The parent term ID.
Context: view, edit
- meta (dict) –
Meta fields.
Context: view, edit
- id (int) –
-
class
wordpress.models.
Comment
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
Media
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
Page
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
Post
(api=None)[source]¶ Bases:
wordpress.models.Model
A WordPress post object.
Parameters: - date (datetime) – The date the object was published, in the site’s timezone.
- date_gmt (datetime) – The date the object was published, as GMT.
- guid (dict) – The globally unique identifier for the object.
- id (int) – Unique identifier for the object.
- link (str) – URL to the object.
- modified (datetime) – The date the object was last modified, in the site’s timezone.
- modified_gmt (datetime) – The date the object was last modified, as GMT.
- slug (str) – An alphanumeric identifier for the object unique to its type.
- status (str) – A named status for the object.
- type (str) – Type of Post for the object.
- password (str) – A password to protect access to the content and excerpt.
- title (dict) – The title for the object.
- content (dict) – The content for the object.
- author (int) – The ID for the author of the object.
- excerpt (dict) – The excerpt for the object.
- featured_media (int) – The ID of the featured media for the object.
- comment_status (str) – Whether or not comments are open on the object.
- ping_status (str) – Whether or not the object can be pinged.
- format (str) – The format for the object.
- meta (list) – Meta fields.
- sticky (bool) – Whether or not the object should be treated as sticky.
- template (str) – The theme file to use to display the object.
- categories (list) – The terms assigned to the object in the category taxonomy.
- tags (list) – The terms assigned to the object in the post_tag taxonomy.
- liveblog_likes (int) – The number of Liveblog Likes the post has.
-
class
wordpress.models.
PostRevision
(api=None)[source]¶ Bases:
wordpress.models.Model
A WordPress post object.
Parameters: - author (int) –
The id for the author of the revision.
Context: view
- date (datetime) –
The date the object was published.
Context: view
- date_gmt (datetime) –
The date the object was published, as GMT.
Context: view
- guid (dict) –
GUID for the object, as it exists in the database.
Context: view
- id (int) –
Unique identifier for the object.
Context: view
- modified (datetime) –
The date the object was last modified.
Context: view
- modified_gmt (datetime) –
The date the object was last modified, as GMT.
Context: view
- parent (int) –
The id for the parent of the object.
Context: view
- slug (str) –
An alphanumeric identifier for the object unique to its type.
Context: view
- title (str) –
Title for the object, as it exists in the database.
Context: view
- content (str) –
Content for the object, as it exists in the database.
Context: view
- excerpt (str) –
Excerpt for the object, as it exists in the database.
Context: view
- author (int) –
-
class
wordpress.models.
PostStatus
(api=None)[source]¶ Bases:
wordpress.models.Model
A WordPress post object.
Parameters: - name (str) –
The title for the resource.
Context: embed, view, edit
- private (bool) –
Whether posts with this resource should be private.
Context: edit
- protected (bool) –
Whether posts with this resource should be protected.
Context: edit
- public (bool) –
Whether posts of this resource should be shown in the front end of the site.
Context: view, edit
- queryable (bool) –
Whether posts with this resource should be publicly-queryable.
Context: view, edit
- show_in_list (bool) –
Whether to include posts in the edit listing for their post type.
Context: edit
- slug (str) –
An alphanumeric identifier for the resource.
Context: embed, view, edit
- name (str) –
-
class
wordpress.models.
PostType
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
ResultSet
[source]¶ Bases:
list
A list of like object that holds results from the WordPress API query.
-
class
wordpress.models.
Setting
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
Tag
(api=None)[source]¶ Bases:
wordpress.models.Model
A WordPress post object.
Parameters: - id (int) –
Unique identifier for the term.
Context: view, embed, edit
- count (int) –
Number of published posts for the term.
Context: view, edit
- description (str) –
HTML description of the term.
Context: view, edit
- link (str) –
URL of the term.
Context: view, embed, edit
- name (str) –
HTML title for the term.
Context: view, embed, edit
- slug (str) –
An alphanumeric identifier for the term unique to its type.
Context: view, embed, edit
- taxonomy (str) –
Type attribution for the term.
Context: view, embed, edit
One of: category, post_tag, nav_menu, link_category, post_format
- meta (dict) –
Meta fields.
Context: view, edit
- id (int) –
-
class
wordpress.models.
Taxonomy
(api=None)[source]¶ Bases:
wordpress.models.Model
-
class
wordpress.models.
User
(api=None)[source]¶ Bases:
wordpress.models.Model
Module contents¶
-
class
wordpress.
WordPress
(url, verify_ssl=True)[source]¶ Bases:
object
-
create_post
(date=None, date_gmt=None, slug=None, status=None, password=None, title=None, content=None, author=None, excerpt=None, featured_media=None, comment_status=None, ping_status=None, format=None, meta=None, sticky=None, template=None, categories=None, tags=None, liveblog_links=None)[source]¶ Create a Post.
Parameters: - date (datetime) – The date the object was published, in the site’s timezone.
- date_gmt (datetime) – The date the object was published, as GMT.
- slug (str) – An alphanumeric identifier for the object unique to its type.
- status (str) –
A named status for the object.
One of: publish, future, draft, pending, private
- password (str) – A password to protect access to the content and excerpt.
- title (str) – The title for the object.
- content (str) – The content for the object.
- author (id) – The ID for the author of the object.
- excerpt (str) – The excerpt for the object.
- featured_media (int) – The ID of the featured media for the object.
- comment_status (str) –
Whether or not comments are open on the object.
One of: open, closed
- ping_status (str) –
Whether or not the object can be pinged.
One of: open, closed
- format (str) –
The format for the object.
One of: standard
- meta (dict) – Meta fields.
- sticky (bool) – Whether or not the object should be treated as sticky.
- template (str) –
The theme file to use to display the object.
One of:
- categories (str) – The terms assigned to the object in the category taxonomy.
- tags (str) – The terms assigned to the object in the post_tag taxonomy.
- liveblog_likes (str) – The number of Liveblog Likes the post has.
-
delete_post
(pk, force=False)[source]¶ Delete a Post.
Parameters: - pk (int) – The post id you want to delete.
- force (bool) – Whether to bypass trash and force deletion.
-
delete_post_revision
(parent, pk)[source]¶ Delete Post Revision.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- pk (int) – Unique identifier for the object.
Returns: Return type: dict
-
get_category
(pk, context='view')[source]¶ Retrieve a Category.
Parameters: - pk (int) – The category id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
get_post
(pk, context='view', password=None)[source]¶ Retrieve a Post.
Parameters: - pk (in) – The post id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- password (str) – The password for the post if it is password protected.
Returns: Return type:
-
get_post_revision
(parent, pk, context='view')[source]¶ Get a Post Revision.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- pk (int) – Unique identifier for the object.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view
Returns: Return type:
-
get_post_status
(slug, context='view')[source]¶ Retrieve a Post statuses
Parameters: - slug (str) – The name of the status.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
get_tag
(pk, context='view')[source]¶ Retrieve a Tag.
Parameters: - pk (int) – The tag id you want to retrieve.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: Return type:
-
list_categories
(context='view', page=1, pre_page=10, search=None, exclude=None, include=None, order='asc', orderby='name', hide_empty=False, parent=None, post=None, slug=None)[source]¶ Get a list of categories.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) –
Current page of the collection.
Default: 1
- pre_page (int) –
Maximum number of items to be returned in result set.
Default: 10
- search (str) – Limit results to those matching a string.
- exclude (int) –
Ensure result set excludes specific IDs.
Default:
- include (int) –
Limit result set to specific IDs.
Default:
- order (str) –
Order sort attribute ascending or descending.
Default: asc
One of: asc, desc
- orderby (str) –
Sort collection by term attribute.
Default: name
One of: id, include, name, slug, term_group, description, count
- hide_empty (bool) – Whether to hide terms not assigned to any posts.
- parent (int/wordpress.models.Category) – Limit result set to terms assigned to a specific parent.
- post (int/wordpress.models.Post) – Limit result set to terms assigned to a specific post.
- slug (str) – Limit result set to terms with a specific slug.
Returns: A list of wordpress.models.Category.
Return type: list
- context (str) –
-
list_post_revisions
(parent, context='view')[source]¶ List Post Revisions.
Parameters: - parent (int/wordpress.models.Post/wordpress.models.Page) – The id for the parent of the object.
- context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view
Returns: A list of wordpress.models.PostRevision.
Return type: list
-
list_post_statuses
(context='view')[source]¶ Get a list of post statuses.
Parameters: context (str) – Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
Returns: A list of wordpress.models.PostStatus Return type: list
-
list_posts
(context='view', page=1, pre_page=10, search=None, after=None, author=None, author_exclude=None, before=None, exclude=None, include=None, offset=None, order='desc', orderby='date', slug=None, status='publish', categories=None, cateogries_exclude=None, tags=None, tags_exclude=None, sticky=None)[source]¶ Get a list of posts.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) – Current page of the collection.
- pre_page (int) – Maximum number of items to be returned in result set.
- search (str) – Limit results to those matching a string.
- after (datetime) – Limit response to posts published after a given date.
- author (int) – Limit result set to posts assigned to specific authors.
- author_exclude (int) – Ensure result set excludes posts assigned to specific authors.
- before (datetime) – Limit response to posts published before a given date.
- exclude (int) – Ensure result set excludes specific IDs.
- include (int) – Limit result set to specific IDs.
- offset (int) – Offset the result set by a specific number of items.
- order (str) –
Order sort attribute ascending or descending.
Default: desc
One of: asc, desc
- orderby (str) – Sort collection by object attribute. Default: date One of: date, relevance, id, include, title, slug
- slug (str) – Limit result set to posts with one or more specific slugs.
- status (str) –
Limit result set to posts assigned one or more statuses.
Default: publish
One of: publish, future, draft, pending, private
- categories (str) – Limit result set to all items that have the specified term assigned in the categories taxonomy.
- categories_exclude (str) – Limit result set to all items except those that have the specified term assigned in the categories taxonomy.
- tags (str) – Limit result set to all items that have the specified term assigned in the tags taxonomy.
- tags_exclude (str) – Limit result set to all items except those that have the specified term assigned in the tags taxonomy.
- sticky (bool) – Limit result set to items that are sticky.
Returns: A list of wordpress.models.Post.
Return type: list
- context (str) –
Get a list of tags.
Parameters: - context (str) –
Scope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
- page (int) –
Current page of the collection.
Default: 1
- per_page (int) –
Maximum number of items to be returned in result set.
Default: 10
- search (str) – Limit results to those matching a string.
- exclude (str) –
Ensure result set excludes specific IDs.
Default:
- include (list) –
Limit result set to specific IDs.
Default:
- offset (int) – Offset the result set by a specific number of items.
- order (str) –
Order sort attribute ascending or descending.
Default: asc
One of: asc, desc
- orderby (str) –
Sort collection by term attribute.
Default: name
One of: id, include, name, slug, term_group, description, count
- hide_empty (bool) – Whether to hide terms not assigned to any posts.
- post (int) – Limit result set to terms assigned to a specific post.
- slug (str) – Limit result set to terms with a specific slug.
Returns: A list of wordpress.models.Category.
Return type: list
- context (str) –
-
update_post
(pk, date=None, date_gmt=None, slug=None, status=None, password=None, title=None, content=None, author=None, excerpt=None, featured_media=None, comment_status=None, ping_status=None, format=None, meta=None, sticky=None, template=None, categories=None, tags=None, liveblog_links=None)[source]¶ Update a Post.
Parameters: - pk (int) – The ID of the post you want to update.
- date (datetime) – The date the object was published, in the site’s timezone.
- date_gmt (datetime) – The date the object was published, as GMT.
- slug (str) – An alphanumeric identifier for the object unique to its type.
- status (str) –
A named status for the object.
One of: publish, future, draft, pending, private
- password (str) – A password to protect access to the content and excerpt.
- title (str) – The title for the object.
- content (str) – The content for the object.
- author (id) – The ID for the author of the object.
- excerpt (str) – The excerpt for the object.
- featured_media (int) – The ID of the featured media for the object.
- comment_status (str) –
Whether or not comments are open on the object.
One of: open, closed
- ping_status (str) –
Whether or not the object can be pinged.
One of: open, closed
- format (str) –
The format for the object.
One of: standard
- meta (dict) – Meta fields.
- sticky (bool) – Whether or not the object should be treated as sticky.
- template (str) –
The theme file to use to display the object.
One of:
- categories (str) – The terms assigned to the object in the category taxonomy.
- tags (str) – The terms assigned to the object in the post_tag taxonomy.
- liveblog_likes (str) – The number of Liveblog Likes the post has.
-
update_setting
(title=None, description=None, url=None, email=None, timezone=None, date_format=None, time_format=None, start_of_week=None, language=None, use_smilies=None, default_category=None, default_post_format=None, post_pre_page=None)[source]¶ Update WordPress settings.
Parameters: - title (str) – Site title.
- description (str) – Site description.
- url (str) – Site URL.
- email (str) – This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. The new address will not become active until confirmed.
- timezone (str) – A city in the same timezone as you.
- date_format (str) – A date format for all date strings.
- time_format (str) – A time format for all time strings.
- start_of_week (int) – A day number of the week that the week should start on.
- language (str) – WordPress locale code.
- use_smilies (bool) – Convert emoticons like :-) and :-P to graphics on display.
- default_category (int) – Default category.
- default_post_format (str) – Default post format.
- posts_per_page (int) – Blog pages show at most.
-
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/myles/python-wp/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
Python WordPress could always use more documentation, whether as part of the official Python WordPress docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/myles/python-wp/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up python-wp for local development.
Fork the python-wp repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/python-wp.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv python-wp $ cd python-wp/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 python-wp tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/myles/python-wp/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Myles Braithwaite <me@mylesbraithwaite.com>
Contributors¶
None yet. Why not be the first?