This plugin provides a shortcode to get the content of a post based on ID number.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
tests
.editorconfig
.gitignore
.travis.yml
composer.json
get-post-content-shortcode.php
phpunit.xml.dist
readme.md
readme.txt

readme.md

Get Post Content Shortcode

Build Status

This WordPress plugin provides a shortcode to get the content of a post based on ID number.

Usage

[post-content id="42"]

This gets the content of post 42.

[post-content id="42" autop="false"]

This gets the content of post 42 and does not call wpautop on the content.

[post-content id="42" shortcode="false"]

This gets the content of post 42 and does not call do_shortcode on the content.

[post-content id="42" autop="false" shortcode="false"]

This gets the content of post 42 and does not call wpautop or do_shortcode on the content.

[post-content id="42" status="publish,future"]

This gets the content of post 42 only if the post_status is "publish" or "future".

[post-content id="42" field="excerpt"]

This gets the excerpt of post 42.

Filter examples

Only allow the post_content field

add_filter('post-content-allowed-fields', function($allowed_fields) {
  return [ 'post_content' ];
});

Set the default value of the autop attribute to false

add_filter('post-content-default-attributes', function ($default_attributes) {
  return [ 'autop' => false ];
});

Tests

setup instructions

vendor/bin/phpunit