MediaPress provides easy to use shortcode with infinite flexibility to list galleries. By the end of August, 2015; we will be providing a TinyMCE plugin to add these in the WordPress post editor.
Shortcode:-
[mpp-list-gallery]
It has around 30 options to list galleries. We will see all of these in example below.
The default syntax is:-
[mpp-list-gallery option_name=some value option1_name = some other value … ]
Allowed Options:-
- Gallery Type Parameters
- Component Parameters
- Status Parameters
- Gallery Parameters
- User Parameters
- Search Parameters
- Date Parameters
- Custom Fields Parameters
- View Parameters
- Pagination parameters
- Gallery Creator Parameters
Gallery Type Parameters:-
type:- Allowed gallery type. Possible values are
- all
- photo
- audio
- video
- doc
Using ‘all‘ will return all types of gallery. You can use ‘photo‘, ‘audio‘, ‘video‘ , ‘doc‘ to list only galleries of these type.
Component Parameters:-
component:- The allowed components for which a gallery can be created.
Possible values are:-
- members
- groups
- sitewide
Using component=members will only list galleries from users. Using ‘groups‘ will list group galleries and ‘sitewide’ will list sitewide galleries. If you don’t specify a value, It will list galleries from users as well as groups both.
component_id:- Component id can be used to get galleries from specific users or groups. It depends on the ‘component’ option. The component option must be specified. If component is ‘members’ then the component_id is treated as user id else group id.
Status Parameters:-
status:- Status limits gallery with particular status to be listed. If you don’t specify it, default is ‘public’.
Possible status values are:-
- public
- private
- loggedin
- friendsonly
- followers
- following
The last two ( followers, following) is only applicable when BuddyPress Followers plugin is enabled.
Gallery Parameters:-
id:- Specific gallery id which you want to list. Only one gallery will be listed
slug:- Only a gallery with this slug will be listed.
in:- Comma separated list of gallery ids which you want to include in the list. Only these galleries will be listed.
exclude: Comma separated list of gallery ids which you don’t want to include in the listing.
User specific parameters:-
user_id:- You can specify the numeric user ID. It will return all galleries for the given user
user_name:- You can use user’s login name(username) instead of the id as above.
include_users:- A comma separated list of numeric users ids. It will limit the galleries to be listed from only these users.
Example:-
[mpp-list-gallery include_user=’1,2,3,4,5′] will list galleries for the specified 5 users.
exclude_users:- A comma separated list of numeric user ids. It excludes galleries from the specified users in the current gallery list.
Example:-
[mpp-list-gallery exclude_users=’1,2,3′] won’t list galleries from users with ID 1 or 2 or 3.
for:- Specify dynamic user context to list the gallery from a particular user. Possible values are ‘logged’, ‘displayed’, ‘author. Available since 1.3.5.
Example:- List galleries for the logged in user.
[mpp-list-gallery for=”logged” type=”photo”]
It will list photo galleries of the currently logged in user. If the user is not logged in, It will not show anything
Example:- List gallery for displayed user.
[mpp-list-gallery for=”displayed” type=”photo”]
It will list the galleries of the user only if we are using it on a user’s profile.
To show the galleries of an author(post author), you can use the following shortcode.
[mpp-list-gallery for=”author” type=”photo”]
It won’t work outside the post context.
Search Parameters:-
search_terms:- You can use it to list the galleries whose title or description matches the given value.
Example:-
[mpp-list-gallery search_terms=’life’] will only list galleries that have the word ‘life’ in either title or description.
Date Parameters:-
year:- List galleries created in the given year.
Example:-
[mpp-list-gallery year=2015] will only list the galleries which were created in 2015.
month:- List the galleries created in a particular month. Possible values are 1-12.
Example:
[mpp-list-gallery month=2] will only list the galleries which were created in the month of February.
week:- You can specify the week number from which the gallery should be listed.
Possible values are from 1-53
For other possible values, please take a loo at WP_Query Date Parameter for possible values and their meaning. date_query parameter is not supported at the moment.
Custom Fields Parameters:-
The shortcode supports meta_key and meta_value parameter. The MPP_Gallery_Query (documentation coming soon) supports meta_query parameter but it is not supported in shortcode.
Please take a look at WP_Query documentation for custom fields section here to understand it.
Example:-
[mpp-list-gallery meta_key=’is_featured’] will only list galleries that have a meta key named ‘is_featured’
View Parameters:-
column:-
- type:- integer
- default: 4
- It is used to display the gallery list in grid. Default value is 4. it defins how many galleries should be listed per row.
Pagination Parameters:-
per_page:-
- type: integer
- controls how many galleries to list per page
offset:-
- type: integer
- how many galleries from the list to offset/displace( exclude from beginning of the original list)
page:- It is same as the ‘paged’ parameter of WP_Query, Which page of result you want to display.
nopaging:- If you want to list all galleries. Please avoid it as It can lead to degraded performance. Always use per_page instead.
Reference:- WP_Query Pagination Parameters.
Gallery Creator Parameters:-
show_creator:-
- type: integer, default 0.
- controls whether to show the gallery creator or not.
before_creator:-
- type: string
- Use any markup or string you want to put before the gallery creator’s name.
after_creator:-
- type: string
- Use any markup or string you want to put after the gallery creator’s name.
Example:-
[mpp-list-gallery show_creator=1 before_creator=”By: ” ]