lonekorean/wordpress-export-to-markdown

Maybe useful | Ways to add custom additional info (Like post_id, author_id etc)

Closed this issue · 2 comments

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

  1. edit from cpanel or direct from your server or localhost /wp-admin/includes/export.php
  2. search <item>
  3. 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>
  1. save & export again from wordpress (don't forget to refresh page)
  2. Check your xml files and search <authorid> for confirmation step is successful
  3. open your wordpress-export-to-markdown directory
  4. 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),
        },
  1. 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.
  1. Additional, coverImage: "xxxxx.jpg", you will need install this plugins https://wordpress.org/plugins/export-media-with-selected-content/
  2. Open wordpress tools->export
  3. Checklist in bottom section and export again

Hey! How exactly do you write the cover image functions? Keeps returning undefined for me...

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.