This is a python project that works with Obsidian to push Markdown to WordPress. Specifically, it works with the Templater plugin.
- Parsing Markdown
- Push Markdown to WordPress (If your article don't have any local attachments. It can push now)
- Custom settings
- Upload attachments
- User parameter verification
- Optimize some details
The python3.11 used during the development of this project, it is recommended to use this version.
If you don't know how to install python and add environment path. Please see this documents.
-
Add plug-in -
WordPress REST API Authentication
in your WordPress. -
Open the plug-in and follow the prompts to create a BASIC AUTHENTICATION.
Install Templater plugin in third-party community.
git clone https://github.com/leitaosha/post-wordpress.git
(Recommend)
or
Download source code. Click to download
Enter the project root directory and execute pip install -r requirements.txt
-
Open the root directory of the project and edit
settings.py
。It is highly recommended that you create a copy ofsettings.py
and name itprivate_settings.py
. Then editprivate_settings.py
for protecting your password. -
Set up Templater plug-in to run python scripts. You need
python.exe
path,push_wp.py
path and a template, see [push wp template](./doc/push wp template.md). -
<your python path> <path of push_wp.py> "<% tp.file.path() %>"
For example:
E:\venv\Scripts\python.exe E:\postWordpress\push_wp.py "<% tp.file.path() %>"
# Your BASIC AUTHENTICATION.
# 你的 BASIC AUTHENTICATION
USERNAME = ''
PASSWORD = ''
WORDPRESS_SITE = ''
# Post Default Options
# 推送默认设置
WP_OPTIONS = {
# article status in wordpress : draft(suggest), publish(suggest), private, future, pending
# 文章发布状态
'status': 'publish',
# article comment status in WordPress : open, closed
# 文章的是否可以评论
'comment_status': 'open',
# Whether to pin this article to the top
# 置顶文章
'sticky': 'false',
# 是否可以ping(建议不做更改)
'ping_status': 'closed',
# 文章形式
'format': 'standard',
}
title
, categories
, and tags
need to be written separately under the first-level fields, and other setting fields are placed in the wp
field.
Settings in markdown file take precedence over settings.py
Example:
---
title: # your article title
tags:
- tag1
categories: # which categories of WordPress you want to push
- category1
excerpt: # excerpt or abstract
wp:
status: publish
slug: # For friendly links, pure English numbers and underlines are recommended.
# there are many params, please see https://developer.wordpress.org/rest-api/reference/posts/ ....
---