ivycat / posts-in-page

Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more
GNU General Public License v2.0
27 stars 19 forks source link

Posts in Page

Contributors: ivycat, sewmyheadon, anvilzephyr, jasonm4563, pjackson1972
Tags: shortcode, pages, posts, custom post types, taxonomy, terms
Requires at least: 3.0
Tested up to: 6.1.1
Stable tag: 1.4.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Easily add one or more posts to any page using simple shortcodes.

Description

Easily add one or more posts to any page using simple shortcodes.

Supports categories, tags, custom post types, custom taxonomies, date ranges, post status, and much more.

You can get all of the same functionality provided by this plugin by modifying your theme's template files; this plugin just makes it easy for anyone to pull posts into other areas of the site without having to get their hands dirty with code.

Plugin is depending upon your theme's styling; version 1.x of this plugin does not contain native styles.

This is a minimal plugin, function over form. Give us feedback, suggestions, bug reports, and any other contributions on the in the plugin's GitHub repository.

Installation

You can install from within WordPress using the Plugin/Add New feature, or if you wish to manually install:

  1. Download the plugin.
  2. Upload the entire posts-in-page directory to your plugins folder
  3. Activate the plugin from the plugin page in your WordPress Dashboard
  4. Start embedding posts in whatever pages you like using shortcodes.

Shortcode Usage

To 'pull' posts into a page, you can:

  1. place a shortcode in the editor window of the page you're editing (Classic Editor),
  2. place a shortcode in a shortcode block on the page you're editing (Gutenberg Editor),
  3. modify a theme template file using the shortcode in a PHP function.

Using Shortcodes in the WordPress editor

Or any combination of the above.

Shortcode Examples

Not sure how to use the shortcodes above to get what you want? Here are a few examples to get you started:

Example 1

Let's say you want to pull a specific post called "What I love about coffee", which has a post ID of 34, somewhere on your About Us page. Your shortcode should look like this:

[ic_add_posts ids='34']

Example 2

Alright, now let's say that you want to pull in all posts from two categories into your WordPress page. One category is WordPress Rocks and the other is WordPress Rolls. Plus, you'd like to display them three per page, rather than the default number of posts. Depending on your category slugs, your shortcode should probably look like this:

[ic_add_posts category='wordpress-rocks,wordpress-rolls' showposts='3']

Example 3

Now, you're ambitious and want to try something complex. Let's say you've got a page called Plugins Are Awesome and, in it, you want to pull in posts that match the following criteria:

Your shortcode might look like this:

[ic_add_posts showposts='6' post_type='testimonials' tax='testimonial-type' term='customer' order='ASC' template='my-posts-in-page-template.php']

Using Shortcodes within a PHP function

If you'd like to use this plugin to pull posts directly into your theme's template files, you can drop the following WordPress function in your template files, replacing the [shortcode] part with your, custom shortcode.

<?php echo do_shortcode("[shortcode]"); ?>

Developer Hooks

There are several hooks you can use to filter the output of your template files:

Frequently Asked Questions

What is the point of this plugin?

It allows you to output or embed the posts in any page without modifying WordPress theme templates.

Does it work with Gutenberg?

Absolutely. Just use a Gutenberg Shortcode block or the Classic Edit block to add your shortcode.

Wait! The posts aren't styled like the posts on the rest of my site.

That is likely true. Currently, Posts in Page doesn't output any styles; just some basic markup. To change how the posts appear on the page, you'll need to change the output template.

How do I change the output template?

Simply copy the posts_loop_template.php to your theme directory and make changes as necessary.

You can even rename it - but make sure to indicate that in the shortcode using the template='my-new-template-name.php'.

For file housekeeping, you can also create a posts-in-page folder in your theme to store all of your custom templates. It isn't necessary to specify the posts-in-page folder in your shortcode - Posts in Page will find it automatically. You can even use multiple templates for use with different shortcodes.

Does it work with custom post types?

Absolutely.

Does it work with custom taxonomies?

You bet.

Will it make me coffee?

Not likely, but let us know if it does; then we'll know we have something special.

How can I help?

We'd love feedback, issues, pull requests, and ideas on the Posts in Page GitHub repo.

Screenshots

1. Embed a shortcode into a page, and it will automatically pull in the post(s) you need.

Embed a shortcode into a page, and it will automatically pull in the post(s) you need.

2. Embed shortcode using a Gutenberg shortcode block.

Embed shortcode using a Gutenberg shortcode block.

3. Embed shortcodes directly in your template using do_shortcode.

[missing image]

Changelog

1.4.4

1.4.3

1.4.2

1.4.1

1.4.0

1.3.1

1.3.0

1.2.4

1.2.3

1.2.2

1.2.1

1.2.0

1.1.1

1.1.0

1.0.10

1.0.9

1.0.8

1.0.7

1.0.6

1.0.4

1.0.3

Upgrade Notice

1.4.4

1.4.3

1.4.2

1.4.1

1.4.0

1.3.0

1.2.4

1.2.3

1.2.2

1.2.1

1.2.0

1.1.1

1.1.0

1.0.10

1.0.9

1.0.8

1.0.7

1.0.6

1.0.4

1.0.3