Maybe useful | Ways to add custom additional info (Like post_id, author_id etc)
Closed this issue · 2 comments
uarefans commented
Maybe we need some data from wordpress like user_id, or category_id and etc. The key is in xml files from wordpress.
So yo have to
- edit from cpanel or direct from your server or localhost /wp-admin/includes/export.php
- search
<item>
- add something like this below
<item>...</item>
// for author id
<authorid><?php echo intval( $post->post_author ); ?></authorid>
// for author name
<author><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></author>
- save & export again from wordpress (don't forget to refresh page)
- Check your xml files and search
<authorid>
for confirmation step is successful - open your wordpress-export-to-markdown directory
- Edit src/parser.js
// Add
function getPostAuthor(post) {
return post.author[0];
}
// Add
function getPostAuthorId(post) {
return post.authorid[0];
}
----------
// Edit
// Find frontmatter:
// And Add like this
frontmatter: {
id: getPostId(post),
date: getPostDate(post),
authorid: getPostAuthorId(post),
author: getPostAuthor(post),
slug: getPostSlug(post),
title: getPostTitle(post),
categories: getCategories(post),
tags: getTags(post),
},
- Save and run again and you will be see
id: "12345"
date: "2022-02-22"
authorid: "11"
author: "AAAAAAAA"
slug: "magic-nexea-partnership-elevates-the-growth-of-startups-to-a-total-of-rm41mil-combined-revenues"
title: "MaGIC-NEXEA partnership elevates the growth of startups to a total of RM41mil combined revenues"
categories:
- "AA"
- "BB"
- "FF"
tags:
- "One"
- "Two"
coverImage: "xxxxx.jpg"
---
KUALA LUMPUR, MALAYSIA - [Media OutReach](http://www.media-outreach.com/) - 11 February 2022 - NEXEA's Entrepreneurs Programme and Malaysian Global Innovation and Creativity Centre (MaGIC) renewed their partnership to continue helping startups grow their businesses during this challenging time. Despite the pandemic, the Entrepreneurs Programme continues to provide a platform for tech entrepreneurs to connect with peers and like-minded individuals in an opportunity to grow, gain knowledge, and develop themselves for success.
- Additional, coverImage: "xxxxx.jpg", you will need install this plugins https://wordpress.org/plugins/export-media-with-selected-content/
- Open wordpress tools->export
- Checklist in bottom section and export again
Kiran-Wicksteed commented
Hey! How exactly do you write the cover image functions? Keeps returning undefined for me...
lonekorean commented
Thank you for sharing! The way frontmatter is handled has been rearchitected to make things easier.
Contributors (or people just hacking for their own use) can more easily add frontmatter by following this example.
End users can add/remove/alias frontmatter fields by editing frontmatter_fields
in settings.js.