GetEntry Shortcode

GetEntry Shortcode

What is this GetEntry Shortcode?

This is a powerful shortcode that you can use to get the content of your other posts, pages and portfolio entries. This can be used in multiple ways, to give you an example, you can use it to display any of the following:

  • The most recent post
  • The top 2 most popular (most comments) posts
  • Any random page
  • A preview of a portfolio item complete with image, excerpt and a ‘read more’ button
  • The contents of another page
  • Posts with a specific tag
  • And lots more!

Shortcode Usage

[getentry type="post"               The type of entry to get. This may be either post, page or portfolio.
                                    For advanced users with installed plugins, you can also specify
                                    any post_type here
          num="1"                   The number of entries to get. Put -1 to get ALL entries.
          offset="0"                The number of entries to skip
          id=""                     If you know the ID of the page/post/portfolio item, put it here
                                    to display that entry only. Only a single entry will be displayed
                                    if this is used.
          author=""                 You can put in here the ID or name (slug) of the author you want
                                    to get entries from. You can put in multiple values here separated
                                    by commas
          category=""               You can put in here the ID or name (slug) of the category you want
                                    to get entries from. You can put in multiple values here separated
                                    by commas
          tag=""                    You can put in here the ID or name (slug) of the tag you want to
                                    get entries from. You can put in multiple values here separated
                                    by commas
          orderby="date"            Sort entries by this parameter. Possible values are date, random
                                    or popularity
          order="desc"              The order of the sorted entries by orderby, DESC means descending
                                    order; ASC means ascending order.
          display_preview="true"    If false, preview images will never be displayed
          display_title="true"      If false, the title of the post / page will not be shown
          display_excerpt="true"    If false, no content / text will be displayed
          display_readmore="true"   If false, the “read more” button will never be displayed  
          excerpt_length="50"       The amount of characters of the content to show before placing a
                                    “read more” button. Put in -1 to show the whole content
          readmore="Read more"      The text to display in the “read more” button or link
          readmore_is_button="true" If true, then a “read more” button will be displayed if the excerpt
                                    is too long to display. If false, a text link with an arrow will
                                    be displayed instead.
          preview_height="100"      The height of the preview image in pixels if available
          preview_width="100"       The width of the preview image in pixels if available
          layout="1"                The type of layout to use to display the entry. 
                                    Values may be 1 or 2.
          class=""                  You can specify a CSS class for the shortcode.
/]

Portfolio items always have a preview image, while blog posts may sometimes have preview images. Pages on the other hand don’t have preview images.

For the author, category, and tag parameters you can either use IDs or slug (not the visible name.). Slugs do not have spaces in them, for example, if you have a category named “My Category”, it’s slug most likely is “my-category”. Check the Posts > Categories and Portfolio Items > Portfolio Categories for the slugs and IDs of your categories, and the Tags section in your admin.

You can also use the alias [getentries/].

Check below for extensive examples and at the bottom of the page to get a look at what the layout parameter is for.

Shortcodes gets stripped out in excerpts (but the text is still there). If the excerpt_length is -1 however (displaying the whole content / entry), shortcodes appear fine.


Aliases

You can also use the following aliases for easier usage:

  • [getentries/] – exactly the same as getentry
  • [getpost/] – get a single most recent blog post
  • [getposts/] – get 5 most recent blog posts
  • [getallposts/] – get all blog posts
  • [getportfolio/] – get a single most recent portfolio entry
  • [getportfolios/] – get 5 most recent portfolio entries
  • [getallportfolios/] – get all portfolio entries
  • [getpage/] – get a single most recent page
  • [getpages/] – get 5 most recent pages
  • [getallpages/] – get all pages

Examples

Example 1: Get the most recent post.

[getentry/]

Hello

ytf ytfbytfb6ytf


Example 2: Get a random item from the portfolio but make the preview image larger

[getentry type="portfolio" orderby="random" preview_width="200"/]

Mind The Chat

Mind The Chat is the private messaging in-app solution to manage the communication of any organization. Mind The Chat is the regulated messaging solution for non-personal use unlike Whatsapp or […]


Example 3: Get the 3 most recent posts but display more of the excerpt and modify the ‘read more’ button.

[getentry num="3" readmore_is_button="false" readmore="Click to view the whole post" excerpt_length="150"/]

Hello

ytf ytfbytfb6ytf

 
 

¡Hola mundo!

Bienvenido a WordPress. Esta es tu primera entrada. Edítala o bórrala, ¡y comienza a publicar!.


Example 4: Same as example 3, but this time get 4 of the most recent posts and split them in a 2 column shortcode.

[col2]
 
[getentry num="2" readmore_is_button="false" readmore="Click to view the whole post" excerpt_length="150"/]
 
[/col2]
 
[col2]
 
[getentry num="2" readmore_is_button="false" readmore="Click to view the whole post" excerpt_length="150" offset="2"/]
 
[/col2]

Hello

ytf ytfbytfb6ytf

 

¡Hola mundo!

Bienvenido a WordPress. Esta es tu primera entrada. Edítala o bórrala, ¡y comienza a publicar!.

 

Etiam ac turpis ligula

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non risus eget sapien pellentesque ultrices. Vestibulum sed augue at orci consectetur semper id et metus. Etiam ac turpis ligula, sit […]


Example 5: Get all blog posts which have tags “tag3” or “tag4”

[getentry num="-1" tag="tag3,tag4"/]

Putting multiple values like this can be done for the author, category and tag parameters.

Suspendisse potenti

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non risus eget sapien pellentesque ultrices. Vestibulum sed augue at orci consectetur semper id et metus. Etiam ac turpis ligula, sit […]


Example 6: Get all blog posts which have BOTH tags “tag1” AND “tag2”

[getentry num="-1" tag="tag1+tag2"/]

Putting multiple values like this can be done for the author, category and tag parameters.


Example 7: Get all blog posts which have tags “tag3” or “tag4” AND is categorized as “category-1”

[getentry num="-1" tag="tag3,tag4" category="category-1"/]

Suspendisse potenti

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non risus eget sapien pellentesque ultrices. Vestibulum sed augue at orci consectetur semper id et metus. Etiam ac turpis ligula, sit […]


Types of layouts

Layout 1

[getentry layout="1"/]

Hello

ytf ytfbytfb6ytf


Layout 2

[getentry layout="2"/]

Hello

ytf ytfbytfb6ytf