1. Home
  2. Media
  3. Shortcodes

Shortcodes

How to display posts through shortcode?
Description

Mediafyre has a builtin shortcode mf_media_query to display post from different from different sections e.g. images, videos, audios and wordpress posts If you are new to shortcode then we strongly recomend you to read further about them on wordpress codex [link]

Usage

[mf_media_query]

Parameters
  • columns (int) (optional)Define the number of columns / grid to show the [mf_media_query columns=”3″]
  • masonry (boolean) (optional)Add or remove masonry support
    [mf_media_query masonry=”1″]
  • show_contentShow or hide the content area.
  • words_limitLimit the number of words you want to show in content area default value is 20 words.
    [mf_media_query words_limit=”15″]
  • show_authorShow or hide the author name.
    [mf_media_query show_author=”1″]
  • show_statsshow of hide the statistics
  • show_tagsshow or hide the tags.
    [mf_media_query show_tags=”1″]
  • autoload
    Enable or disable autoload more results on page scroll
  • filterationshow or hide the filteration which is visible at the top of posts.
    [mf_media_query filteration=”1″]
  • templateMediafyre shortcodes have advanced functionality to overwrite the default templates.Following are the default available templates
    1. content-grid-view ( for default grid view )
    2. content-list-view ( for default list view )

    Note: You can also create your own templates by using the following procedure.
    We strongly recommend you to create child theme for all of your custom templates, if you are not familiar with child themes then please have a look at wordress codex.
    1. Create a new file in your child theme root directory or sub-directory e.g. my-custom-template.php or templates/my-custom-template.php in our example we will consider that you created a sub-directory with the name of templates.
    2. Use the template attribute in your shortcode to point the newly created template file without .php extension
    [mf_media_query template=”templates/my-custom-template”] 3. Now write your HTML code and it will start working, to see how the PHP variables and conditions are working there please open the existing template files. note: you can also overwrite the built-in templates through child themes e.g. to customize content-grid-view, create or copy the file in child theme and customize it according to your requirments.
    Please note: Media Query shortcode has another great option and that is you can change the all of the above mentioned parameters for list view, but in case you don’t update then the list views will use grid view parameters values.

    To customize list view parameters just add the keyword “list_” with above mentioned parameters e.g. to change the columns for list view use [mf_media_query list_columns=”2″]
    Please note some of the attributes like templates and masonry will use default values for list view in case the are not defined in shortcode

Additional Parameters
  • has_password (boolean)Show posts with password default is false
    [mf_media_query has_password=”0″]
  • active_viewSwitch the default view between grid and list
    [mf_media_query active_value=”grid”]
  • post_typeFetch posts from the mentioned section
    Supported posts types are post, exc_audio_post, exc_video_post, exc_image_post
    [mf_media_query post_type=”post, exc_audio_post, exc_video_post, exc_image_post”]
  • posts_per_pageThe number of posts to show on each request, the default value is wordpress default posts per page
    [mf_media_query posts_per_page=”20″]Apart from this you can use almost all wordpress WP_Query parameters, following is the list of supported parameters if you are not family how they works then please read about them on wordpress codex [LINK]
  • m
  • p
  • post_parent
  • name
  • pagename
  • page_id
  • second
  • minute
  • hour
  • day
  • monthnum
  • year
  • w
  • category_name
  • tag
  • cat
  • tag_id
  • author
  • author_name
  • paged
  • meta_key
  • meta_value
  • s
  • fields
  • order
  • orderByThe following parameters required arrays as input but shortcodes do not support arrays so pass comma seperated values and system will automatically converts them into array
    e.g. [mf_category__in=”1″] in case you have one value
    e.g. [mf_category__in=”1, 3, 8″] in case of multiple values
  • category__in
  • category__not_in
  • category__and
  • post__in
  • post__not_in
  • tag__in
  • tag__not_in
  • tag__and
  • tag_slug__in
  • tag_slug__and
  • post_parent__in
  • post_parent__not_in
  • author__in
  • author__not_in
How to create a Category and publish a post in it?

This question consists of two parts: first dealing with the creation of a new category and the second part concerned with adding/publishing a post in the category.

Part 1: How to create a new Category?
  • Go to “Posts” => “Categories”
  • As you click on “Categories”, you will be directed to Categories Dashboard. Here you will find input boxes for “Name”, “Slug”, “Parent”, and “Description”. Provide text in these boxes according to your requirement.
  • Scroll the page down and locate the option, “Category Settings”. Under this heading, you can find the sub-headings of “Category Page Layout”, “Sidebar”, “Category Image”, which you need to customize according to your choice.
  • After customizing all the options, click on the option “Add New Category”, and a new category will be added to the categories list given to the right.
Part 2: How to add/publish a post in the newly created Category?
  • Go to “Posts” = “Add New”
  • As you click on “Add New”, you will be directed to Add New Post Dashboard. Here you will find input boxes for title and text. Provide title and text here.
  • Go to the right side of the dashboard and locate “Featured Image” and click on the “Set Featured Image” option given therein. Give path for an image from your PC.
  • Go to Categories box which will contain the list of all the available categories. Locate the newly created category and put a check in it.
  • Click on “Publish/Update”.
How to create a Category and add Main menu?
  • Login to WordPress Admin Panel
  • Go to “Appearance => Menus” on the side menu of WP Dashboard
  • Click on “Categories” and a dropdown list appear.
  • Click on the option “Add to Menu” given at the bottom of the “Categories” box, and the given category will be added.
  • You can set the position/location of the newly added category by “drag & drop” method.
  • Scroll the page down and put a check in the check box of “Main Menu” on the bottom of the dashboard.
  • Click on “Save Menu” on the bottom.

How to create and customize a new Post?

  • Go to “Posts” => “Add New”. Click on “Add New”.
  • Locate the “Add New Post” input box and provide title for the new Post.
  • Go to text area and provide text about the new Post.
  • Scroll the page down and locate the option “Page Settings”, where you can find various editing options, like “Header” and “Layout”.
  • Choose the desired sidebar from the “Sidebar” dropdown list.
  • Click on “Publish/Update” on the WP Dashboard sidebar.

 

  • How to create and customize a new page through Shortcodes?
    • Go to “Pages” => “Add New”.
    • As you click on “Add New”, a new widow will appear on the WP dashboard.
    • Locate the “Add New Page” input box and provide title for the new Page.
    • Scroll the page down and locate the option “Template”, on the WP Dashboard sidebar.
    • Select from the dropdown list “Front page”.
    • Insert the desired shortcodes that you want.
    • Scroll the page down and locate the option “Page Settings”, where you can find various editing options, like “Header” and “Layout”.
    • Choose the desired sidebar from the “Sidebar” dropdown list.
    • Click on “Publish/Update” on the WP Dashboard sidebar.

 

Was this article helpful to you? Yes 1 No