Posts in Page Shortcodes

Below, you’ll find a detailed guide on how to add the Posts in Page Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Posts in Page Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Posts in Page Plugin and the shortcodes it provides:

Plugin Icon
Posts in Page

"Posts in Page is a WordPress plugin that seamlessly integrates your blog posts into any page. It's a versatile tool designed to enhance the organization and presentation of your content."

★★★★✩ (86) Active Installs: 20000+ Tested with: 5.2.19 PHP Version: false
Included Shortcodes:
  • [ic_add_posts]
  • [ic_add_post]

Posts in Page [ic_add_posts] Shortcode

The ‘ic_add_posts’ shortcode is a powerful tool provided by the Posts-in-Page plugin. It fetches and displays posts on a specified page. The PHP function ‘posts_in_page’ uses this shortcode to create a new ICPagePosts object. It then returns the output of the posts, allowing for seamless integration of posts within your pages.

Shortcode: [ic_add_posts]

Examples and Usage

Basic Example – In this basic example, the shortcode is used without any parameters. Hence, it will display the posts as per the default settings.

[ic_add_posts]

Advanced Examples

In the first advanced example, the shortcode is used with the ‘category’ parameter. This will display posts from the specified category. For instance, if you want to display posts from the ‘news’ category, the shortcode would look like this:

[ic_add_posts category='news']

In the second advanced example, the shortcode is used with multiple parameters. Here, it is used with the ‘category’ and ‘showposts’ parameters. This will display a certain number of posts from the specified category. For instance, if you want to display 5 posts from the ‘news’ category, the shortcode would look like this:

[ic_add_posts category='news' showposts='5']

In the third advanced example, the shortcode is used with the ‘tag’ parameter. This will display posts with the specified tag. For instance, if you want to display posts with the tag ‘WordPress’, the shortcode would look like this:

[ic_add_posts tag='WordPress']

In the fourth advanced example, the shortcode is used with the ‘post_type’ parameter. This will display posts of the specified post type. For instance, if you want to display posts of the post type ‘product’, the shortcode would look like this:

[ic_add_posts post_type='product']

PHP Function Code

In case you have difficulties debugging what causing issues with [ic_add_posts] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ic_add_posts', array( $this, 'posts_in_page' ) );

Shortcode PHP function:

function posts_in_page( $atts ) {
		$posts = new ICPagePosts( $atts );

		return $posts->output_posts();
	}

Code file location:

posts-in-page/posts-in-page/posts_in_page.php

Posts in Page [ic_add_post] Shortcode

The ‘ic_add_post’ shortcode from the Posts-in-Page plugin is designed to add specific posts within a page. This shortcode executes the ‘post_in_page’ function, which calls the ‘posts_in_page’ method. This method retrieves and displays the specified posts within the page.

Shortcode: [ic_add_post]

Examples and Usage

Basic example – Utilizing the shortcode to add a specific post in a page by referencing the post’s ID.

[ic_add_post id=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ic_add_post] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ic_add_post', array( $this, 'post_in_page' ) );

Shortcode PHP function:

function post_in_page( $atts ) {
		return self::posts_in_page( $atts );
	}

Code file location:

posts-in-page/posts-in-page/posts_in_page.php

Conclusion

Now that you’ve learned how to embed the Posts in Page Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *