1. Go to this page and download the library: Download grottopress/wordpress-posts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grottopress / wordpress-posts example snippets
declare (strict_types = 1);
use GrottoPress\WordPress\Posts;
// Instantiate Posts
$posts = new Posts([
'image' => [
'size' => 'some-size', //could be array (eg: array(150,150)) or string (eg: 'post-thubnail')
'margin' => '0 10px 0 0',
],
'excerpt' => [
'length' => 30, // number of words. use -1 for all
'after' => [
'types' => ['category', 'post_tag']
]
],
'title' => [
'position' => 'top' // either 'top' or 'side' of image
'tag' => 'h1', // 'h2' by default,
'before' => [
'types' => ['share_link', 'tweet_link'],
],
'after' => [
'types' => ['author_name', 'published_date', 'comments_link'],
]
],
'wp_query' => [ // WP_Query args
// See https://codex.wordpress.org/Class_Reference/WP_Query
]
]);
// Display posts
echo $posts->render();