Skip to content

Campaigns Shortcode

The [campaigns] shortcode allows you to display a collection of campaigns within your posts or pages.

Parameters

  • number: The number of campaigns to show. Set this to -1 to show all campaigns. Defaults to the number of posts you show on blog pages.
  • orderby: The order in which campaigns are displayed. Options include post_date, popular and ending. As of version 1.4, you can also use any of the options that WP_Query accepts. Defaults to post_date.
  • order: Change the direction in which campaigns are ordered. Accepts DESC or ASC. Defaults to DESC.
  • category: Only show campaigns within certain categories, identified by the category slug. Pass multiple category slugs as a comma separate list to include more than one category.
  • creator: Only show campaigns created by a certain user. User must have their user ID passed.
  • exclude: Exclude specific campaigns by their ID. Pass multiple IDs as a comma separated list to exclude more than one.
  • include_inactive: Include campaigns that have expired by setting this to 1 or true. Defaults to false.
  • columns: Choose how many columns you want to display the campaigns in. Supports any number between 1 and 4. Defaults to 2.
  • button: Choose whether you want to show a Donate button (the default), a read more link (button="details"), or nothing at all (button="0").
  • id: Show specific campaigns. You can provide a single number or multiple IDs as a comma separated list.
  • responsive: Scale campaigns to a single-column layout on smaller screens. Set this to 0 to turn off the responsive behaviour, or specify a custom breakpoint with a px or em value. The default breakpoint is 768px.
  • masonry: Display the campaigns in a masonry layout (like Pinterest). Set this to 1 to enable the masonry layout. Defaults to 0.

Usage

Default usage:

[campaigns]

Include expired campaigns:

[campaigns include_inactive=1]

Show 30 campaigns:

[campaigns number=30]

Order campaigns by the amount of money they have raised:

[campaigns orderby=popular]

Order campaigns by how soon they are ending (soonest to end is shown first):

[campaigns orderby=ending]

Only show campaigns within the “environmental issues” category:

[campaigns category=environmental-issues]

Only show campaigns by the user with ID 33:

[campaigns creator=33]

Display campaigns in 3 columns:

[campaigns columns=3]

Show a “read more” link for campaigns:

[campaigns button="details"]

Only display the campaigns with IDs of 33 and 44:

[campaigns id=33,44]

Turn off responsive styling:

[campaigns responsive=0]

Set a custom breakpoint of 600px for responsive styling:

[campaigns responsive=600px]

Extra parameters added by extensions

Ambassadors

If you’re using Charitable Ambassadors version 2.0 or above, there are additional parameters you can use to filter which campaigns are shown:

  • parent: Show only the child campaigns of a specific parent campaign.
  • fundraiser_type: Show only fundraiser campaigns of a specific type. Options include:
    • individual – Individual fundraisers for existing campaigns.
    • team – Team fundraisers for existing campaigns.
    • team-member – Team member campaigns.
    • fundraiser – Any campaign for an existing campaign or the organization.
    • personal – Any campaign for a personal cause.
  • fundraise_button: Whether to show the “Fundraise” button. Defaults to false.
  • join_team_button: Whether to show the “Join Team” button. Defaults to false.

Usage

Show campaigns that are a child of the parent campaign with ID 30:

[campaigns parent=30]

Only show team fundraiser campaigns:

[campaigns fundraiser_type=team]

Only show personal campaigns:

[campaigns fundraiser_type=personal]

Show the “Fundraise” and “Join Team” buttons in the campaign grid:

[campaigns fundraise_button=true join_team_button=true]

Geolocation

If you have Campaigns Geolocation installed, you can display campaigns on a Google Map, with some additional parameters:

  • map: Set to 1 or true to display campaigns on a map. Defaults to false.
  • width: Set how wide you want your map to be. This must be passed as a valid CSS width (400px, 100%, etc). Defaults to 100%.
  • height: Set how high you want your map to be. This must be passed as a valid CSS height. Defaults to 500px.
  • zoom: Set the initial zoom level you would like your map to display at. Defaults to auto, with the zoom level based on the pins that have been added to the map.

Usage

Display campaigns on a map width a width of 900px, height of 600px and zoom level set to 5:

[campaigns map=1 width=900px height=600px zoom=5]