vendredi 8 novembre 2013

WordPress Plugin : Page-In-Page

The Page In Page plugin has a very simple mission: Insert posts and pages within each other
with no stress.

It provides possibilities to use both widgets and shortcodes. If using a widget you are only able to
include pages within pages but if using the shortcode, you are able to able to insert posts/pages
within other posts/pages.

Installation

  1. Download the plugin from http://wordpress.org/plugins/page-in-page/
  2. Extract the zip file. You should find the a folder with name 'page-in-page’.
  3. Upload the 'page-in-page` folder to the `/wpcontent/plugins/` directory
  4. Activate the plugin through the 'Plugins' menu in WordPress Admin
  5. Read the usage instructions below

Usage


Using the widget


The settings in the widget include:

  • Title: Widget Title. This title will be shown as the page's title if 'Show page title' option is not selected.
  • Page: Select the page that will be included when widget is called.
  • Show page title: If checked (selected) then the page title will be shown and the 'Widget Title' ignored.
  • Show title as link: If checked (selected) the title will be displayed as a link to the page.
  • Show page content: If checked (selected) then the page content will be included in the output.
  • Show featured image: If checked (selected) then the featured image will be included in the output.
  • Show featured image as link : If checked (selected) then the featured image will be included and linked to page in the output.
  • Output Template: Insert an HTML template that will be used to display content of the widget. If not provided the default template will be used
    Slugs that can be used in your template are ${page_title}, ${page_content}, ${page_link}, ${page_image} . Each are self explanatory of what they will be replaced with.

  • The default output template is
    <div class="twl-page-in-page">
    <span class="twl-page-in-page-title">${page_title}</span>
    <div class="twl-page-in-page-content">
    <div class="twl-page-in-page-image"><img src="${page_image}" /></div>
    <div class="twl-page-in-page-text">${page_content}</div>
    </div>
    </div>

Using shortcode


With shortcodes, you can insert posts in posts, pages in pages, posts in pages and vice versa.
Settings that can be used in a shortcode are:
  • id : The ID of the page/post you want to insert
  • show_page_title: should the page title be displayed? (Can be 1 for true or 0 for false. Defaults to 1)
  • show_page_content: should the page title be displayed? (Can be 1 for true or 0 for false. Defaults to 1)
  • show_title_as_link: Can be 1 for true or 0 for false. Defaults to 0. If set to 1, the page title will be displayed as a link to the page/post
  • show_featured_image: Can be 1 for true or 0 for false. Defaults to 0. If set to 1, the page's featured image will be included
  • show_featured_image_as_ink: Can be 1 for true or 0 for false. Defaults to 0. If set to 1, the page's featured image will be included as a link

Note that if you are specifying a template in the shortcode, then the above settings will be ignored and the slugs you insert in your template will be replaced with appropriate content. See a template example and allowed slugs above.

To insert a shortcode you can do one of the following:
  • To insert without specifying a template you can simply use
    [twl_page_in id=123] OR [twl_page_in id=123 show_page_title=1].
  • To insert your shortcode specifying a template for page/post's title and content use the following. You can include other supported slugs mentioned above
    [twl_page_in id=123 show_page_title=1]
    <h3 class="my-awesome-title-class">${page_title}</h3>
    <div class="my-awesome-content-class">${page_content}</div>
    [/twl_page_in]

    The template specified in the [twl_page_in] tag will be used to display the page/post with the specified id when inserting it. The template is optional and if not specified then the default template will be used.
    IMPORTANT!!! If you specify a template, you MUST have the slugs you want to be shown else you might get unexpected results
    IMPORTANT!!! This template has to be defined when Editor is in 'Visual' mode and NOT in 'Text' mode (see screen shot). If you do not respect this you might have unexpected results because HTML tags might not be parsed properly. However if you have escaping with magic quotes off on your server then template should be defined when editor is in 'Text' mode.
  • To insert posts from your Facebook page, Go to Admin > Settings > Page In Page Plugin and insert your facebook application credentials. Next edit the page where you want the posts to appear and insert the short code [twl_page_in_fb]
  • To insert tweets from your twitter account, Go to Admin > Settings > Page In Page Plugin and insert your twitter application credentials. Next edit the page where you want the posts to appear and insert the short code [twl_page_in_tw].

2 commentaires: