Skip to main content

Overview

Visual Portfolio provides three shortcodes for displaying portfolios, filters, and sorting controls anywhere in your WordPress content:
  • [visual_portfolio] - Display a portfolio layout
  • [visual_portfolio_filter] - Display a standalone filter
  • [visual_portfolio_sort] - Display a standalone sort control

Portfolio Shortcode

The main shortcode for displaying portfolio layouts.

Basic Usage

Attributes

Defined in /home/daytona/workspace/source/classes/class-shortcode.php:33-40:

Examples

Display a Saved Layout

With Custom CSS Classes

In PHP Template Files

Programmatic Usage

You can also call the shortcode function directly:

Filter Shortcode

Display a standalone category filter that controls a portfolio.

Basic Usage

Attributes

Defined in /home/daytona/workspace/source/classes/class-shortcode.php:52-62:

Examples

Basic Filter

With Item Count

Custom Alignment and Text

In PHP

Sort Shortcode

Display a standalone sorting control for a portfolio.

Basic Usage

Attributes

Defined in /home/daytona/workspace/source/classes/class-shortcode.php:74-82:

Examples

Basic Sort Control

Custom Alignment

In PHP

Shortcode Registration

Shortcodes are registered in the constructor at /home/daytona/workspace/source/classes/class-shortcode.php:19-24:

Combining Shortcodes

You can use multiple shortcodes together to create custom layouts:

Advanced Usage

Dynamic Shortcode Generation

Generate shortcodes dynamically in PHP:

Conditional Display

Widget Areas

Shortcodes work in widget areas:

Shortcode Output

All shortcodes ultimately call Visual_Portfolio_Get::get(), which:
  1. Processes attributes
  2. Loads the layout configuration
  3. Queries content based on settings
  4. Renders the appropriate template
  5. Returns HTML output

Output Structure

Filtering Shortcode Output

You can filter shortcode output:

WPML Integration

Shortcodes automatically support WPML for translated layouts:

Common Use Cases

Page Builder Integration

Use shortcodes in page builders: Elementor:
  • Add a Shortcode widget
  • Insert [visual_portfolio id="456"]
WPBakery Page Builder:
  • Add a Text Block element
  • Insert the shortcode
  • The vc_css attribute is automatically supported
Beaver Builder:
  • Add an HTML module
  • Insert the shortcode

Archive Pages

Display different portfolios on archive pages:

Custom Post Type Archives

ACF Integration

Use with Advanced Custom Fields:

Troubleshooting

Shortcode Not Working

  1. Check ID: Ensure the layout ID exists and is published
  2. Check Syntax: Verify shortcode syntax is correct
  3. Check Filters: Ensure do_shortcode is applied where needed

Styling Issues

  1. Enqueue Assets: Shortcodes automatically enqueue required CSS/JS
  2. Theme Conflicts: Check for CSS conflicts with your theme
  3. Custom Classes: Use the class attribute to add custom styling hooks

Performance

  1. Caching: Use transients to cache shortcode output for heavy queries
  2. Lazy Loading: Enable lazy loading for images in portfolio settings
  3. Pagination: Use pagination for large galleries instead of loading all items

Best Practices

  1. Use Saved Layouts: Create reusable layouts via Visual Portfolio → Add New
  2. Validate IDs: Always validate layout IDs exist before display
  3. Sanitize Attributes: When generating shortcodes dynamically, sanitize all values
  4. Cache Output: Cache expensive shortcode output using transients
  5. Test Responsiveness: Ensure shortcodes display correctly on all devices
  6. Document IDs: Keep track of which layout IDs are used where