$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Export posts manually selected by end user (not logged in)|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Export posts manually selected by end user (not logged in)

matteradmin9PV0评论

For an intranet project, I'd like to have not logged in users be able to manually check posts (with checkbox in front of post title on archive page) and be able to export some predefined data about those posts (ex: title, date, author, acf field...) in a format (json, csv...) I'm quite new to Wordpress development, can someone points me to some direction or resources? Thank you

For an intranet project, I'd like to have not logged in users be able to manually check posts (with checkbox in front of post title on archive page) and be able to export some predefined data about those posts (ex: title, date, author, acf field...) in a format (json, csv...) I'm quite new to Wordpress development, can someone points me to some direction or resources? Thank you

Share Improve this question asked Dec 6, 2018 at 15:36 Anthony BrebionAnthony Brebion 212 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I would recommend doing it mostly in Javascript:

Basic steps (pseudo code):

  1. On the archive page add check boxes <input type="checkbox" name="post-with-id-1" value="1"> next to each post and a submit button <input type="submit" value="Submit"> at the top or bottom of the page.
  2. In js, listen for clicks on the submit button. When it is clicked check which checkboxes are checked and create an array of post ids.
  3. The simplest thing to do then would be to build a url that opens a page in the browser from the REST API like this http://demo.wp-api/wp-json/wp/v2/posts?include[]=470&include[]=469 where you append an 'include[]=470' for each of the selected posts. That url will build JSON Array that includes object representations of each of your posts.
Post a comment

comment list (0)

  1. No comments so far