TPG Get Posts Documentation

 

[tpg_get_posts]

[tpg_get_posts fields="title ,byline,content,metadata" numberposts=5
field_classes="post_title=tpg-title-class,post_content=tpg-content-class,
post_metadata=tpg-metadata-class, post_byline=tpg-byline-class" ]

[tpg_get_posts tag="tag1, tag2,tag3"]

[tpg_get_posts cat="homepage" numberposts=2]

  1. <?php echo do_shortcode('[tpg_get_posts]'); ?>

  • get_posts template tag, all of the possible parameters associated with this plugin are documented in the WP_Query class to which fetches posts. See the parameters section of the WP_Query documentation for a list of parameters that this function accepts.

    Note that if the parameter expects an array, then it must be handled explicitly in the parameter interface. If that is not listed here, then it is not accepted.','tpg-get-posts')?>

    tag
    tag_id
    author__in
    author__not_in
    cat
    These are OR logic comparisons. Examples: cat='4', cat='5,3,4', cat='news,events,5' cat='news'. The category name is the name and not the slug. The coversion routine will look for id, slug and then category. To accomodate complex taxonomonies and where a category name is repeated as a sub category use either slug or id. Slugs and id''s are unique where a category name can be repeated.",'tpg-get-posts')?>
    cat_link
    numberposts
    offset
    posts_per_page
    fp_pagination
    post_parent__in
    post_parent__not_in
    post__in
    post__not_in
    post_type
    With the premimun extension, you may select multiple posts types by entering post_type="CustTyp1,CustTyp2". The post type can be found by editing a custom post and checking the permalink which is below the post title. The custom post type immediately follows the domain name.','tpg-get-posts')?>
    post_status
    With the premimun extension, you may select multiple posts statuses by entering post_status="published,draft".','tpg-get-posts')?>
    ignore_sticky_posts
    category__and
    category__in
    category__not_in
    tag__and
    tag__in
    'tag__not_in
    tag_slug__and
    tag_slug__in
    query_by_date

    tax_query

    %s

    **Note: that json requires the strings to be enclosed with double quotes, so single quotes are required to wrap the tag value. Also json uses [] to define arrays without keys, but that conflicts with the shortcode syntax. To work around this, () are substitued in the json string and converted before decoding to an array.','tpg-get-posts'),'tax_query=\'{"relation":"AND","0":{"taxonomy":"movie_genre","field":"slug","terms":("action","comedy")},"1":{"taxonomy":"actor","field":"id","terms":(103,115,206),"operator":"NOT IN"}}\'')?>
    meta_query

    %s

    **Note: that json requires the strings to be enclosed with double quotes, so single quotes are required to wrap the tag value. Also json uses [] to define arrays without keys, but that conflicts with the shortcode syntax. To work around this, () are substitued in the json string and converted before decoding to an array.','tpg-get-posts'),'meta_query=\'({"key":"color","value":"blue","compare":"NOT LIKE"},{"key":"price","value":(20,100),"type":"numeric","compare":"BETWEEN"})\'')?>

    fields
    field_classes

    The following is a list of the default field classes which can be overridden:','tpg-get-posts')?>

    • post_title=tpg-title-class
    • post_content=tpg-content-class
    • post_metadata=tpg-metadata-class
    • post_byline=tpg-byline-class
    • post_thumbnail=tpg-thumbnail-class
    • thumbnail_align=alignleft
    • post_excerpt=tpg-excerpt-class
    • mag_content=tpg-mag-class
    • fi_content=tpg-fi-class
    • ul_class=tpg-ul-class
    • pagination=tpg-pagination-class
    • page-next=tpg-next
    • page-prev=tpg-prev
    • more_link=more-link
    fi_layout
    The thumbnail_size is required when displaying the thumbnail/featured image.','tpg-get-posts')?>
    mag_layout
    The thumbnail_size is required when displaying the thumbnail/featured image.','tpg-get-posts')?>
    more_link_text
    page_next
    page_prev_text
    page_next_text
    shorten_title
    shorten_content
    Also note that this command does not check for embedded tags. It trims the content when the limit is reached and is not aware of html tags. Thus tags can be broken. It should only be be used with content that is very controlled. Using the read-more tag is safer.','tpg-get-posts')?>
    show_entire
    show_excerpt
    tag_link
    text_ellipsis
    thumbnail_size
    thumbnail_only
    thumbnail_link
    thumbnail_title
    title_tag
    .','tpg-get-posts')?>
    title_link
    ul-class

    cf
    ppre => ppst => pre => pst => t,b,c,m =>
    cfp

    user-get-posts-style.css. When the plugin is loaded, the standard style sheet is loaded and then the user defined style sheet is loaded, if it exists. Any tags in the user style-sheet will override the standard style.','tpg-get-posts')?>

    1. tpg-title-class
      tpg-byline-class
      tpg-content-class
      tpg-metadata-class
      tpg-excerpt-class
      tpg-thumbnail-class

    2. [tpg_get_posts show_entire="false" fields="title, content, metadata" numberposts=5
      field_classes="post_title=tpg-title-class, post_content=tpg-content-class,
       post_metadata=tpg-metadata-class,post_byline=tpg-byline-class"  ]


      Within each line, there are several post tags which can be displayed and each tag can be formatted.','tpg-get-posts')?>
    • auth -
    • cat -
    • cmt -
    • dp -
    • dm -
    • tag -
    • tm -
    • tp -
    • byline_fmt
      metaline_fmt

      Note: if you wish to use a comma in the the formatting, use the code &#44; The parsing routine uses commas to parse the format options, so the html code must be used to circumvent the parser. ','tpg-get-posts')?>

      auth_fmt
      cat_fmt
      cmt_fmt
      dp_fmt
      dm_fmt
      tag_fmt
      Tags: ," (separator,b4 text,after text)','tpg-get-posts')?>
      tm_fmt
      tp_fmt

    Filters:

    The filter process allows for the filters to be implemented in 2 ways:

    1. Globally as a standard filter
    2. Individual call in tpg_get_posts

    The global filter is given a priority value of 10 and the call through the short-code is given a priority value of 15. This allows the short-code call to override the global call, it that it is called after the global call.

    Example code

    Create a custom function. This can be placed in the theme functions file or it can be put in a file named
    "user-get-posts-custom-functions" which is placed in the root of the theme.

    function my_custom_title_filter( $title, $post) {
            $title = "Custom Title Filter Works";
            return $title;
        }

    To set the function to process on all titles (global title filter) use the following code and add below the function definition:
    'add_filter( "tgp_filter_title", "my_custom_title_filter", 10, 2 );

    To run the filter for a specific call of tpg_get_posts add the filter parameter to the short-code:
    [tpg_get_posts filter_title="my_custom_title_filter"]>

    The query filter only passes one argument, the query arguments array:

    function my_custom_filter_query( $args) {
             *** set the $args array ***
            return $args;
        }
    [tpg_get_posts filter_title="my_custom_filter_query"]>

    The available filters are:
    (replace <function_name> with your custom function name)

      filter_query
      filter_query="<function_name>" - this function only accepts one argument, the query parameters array. This filter allows the wp_query parameters to be modified before the query is run.
      filter_title
      filter_title="<function_name>"
      filter_byline
      filter_byline="<function_name>"
      filter_content
      filter_content="<function_name>"
      filter_metadata
      filter_metadata="<function_name>"
      filter_thumbnail
      filter_thumbnail="<function_name>"

    [tpg_get_posts tag="tag1,tag2" numberposts=5 orderby="title"]

    [tpg_get_posts cat="Events,News" numberposts=2 orderby="title" show_entire="true"]

    [tpg_get_posts tag="tag5" fields="title"  ul_class="tpg-ul-class"]

    [tpg_get_posts cat="15,-4" ]

    [tpg_get_posts cat="25" fields="title, byline"  numberposts=1 mag_layout="true" thumbnail_size="thumbnail"]

    [tpg_get_posts cat="cat1" posts_per_page=5
    		 field_classes="pagination=tpg-pagination-class my-theme-pagination-class"]

    [tpg_get_posts cat="cat1" posts_per_page=5
    		 field_classes="pagination=tpg-pagination-class
    		 my-theme-pagination-class" fp_pagination="true"]

    [tpg_get_posts category__in="Events" byline_fmt"auth,dm,tm", dm_fmt="F j&#44; Y, last changed on: ,"]

    1. [tpg_get_posts cat="homepage" numberposts=2]

    Comments are closed.