adjustable post type

This commit is contained in:
Tobias Buss 2023-10-09 18:13:00 +02:00
parent 96384abf5a
commit 814694c97e

View File

@ -12,7 +12,8 @@ Module.register('MMM-Wordpress', {
defaults: {
updateInterval: 600000, // 10 minutes
url: 'YOUR_WORDPRESS_API_URL', // replace with your WordPress API endpoint
numberOfPosts: 5 // number of posts to display
numberOfPosts: 5, // number of posts to display
posts: 'posts', //Endpoint ("posts" for normal posts, can be changed to custom post type)
},
start: function() {
@ -25,11 +26,12 @@ Module.register('MMM-Wordpress', {
getPosts: function() {
const url = this.config.url;
const posts = this.config.posts;
const numberOfPosts = this.config.numberOfPosts;
const request = require('request');
request.get(`${url}/wp-json/wp/v2/posts?per_page=${numberOfPosts}`, (error, response, body) => {
request.get(`${url}/wp-json/wp/v2/${posts}?per_page=${numberOfPosts}`, (error, response, body) => {
if (!error && response.statusCode == 200) {
this.posts = JSON.parse(body);
this.updateDom();