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 callVisual_Portfolio_Get::get(), which:
- Processes attributes
- Loads the layout configuration
- Queries content based on settings
- Renders the appropriate template
- 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"]
- Add a Text Block element
- Insert the shortcode
- The
vc_cssattribute is automatically supported
- 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
- Check ID: Ensure the layout ID exists and is published
- Check Syntax: Verify shortcode syntax is correct
- Check Filters: Ensure
do_shortcodeis applied where needed
Styling Issues
- Enqueue Assets: Shortcodes automatically enqueue required CSS/JS
- Theme Conflicts: Check for CSS conflicts with your theme
- Custom Classes: Use the
classattribute to add custom styling hooks
Performance
- Caching: Use transients to cache shortcode output for heavy queries
- Lazy Loading: Enable lazy loading for images in portfolio settings
- Pagination: Use pagination for large galleries instead of loading all items
Best Practices
- Use Saved Layouts: Create reusable layouts via Visual Portfolio → Add New
- Validate IDs: Always validate layout IDs exist before display
- Sanitize Attributes: When generating shortcodes dynamically, sanitize all values
- Cache Output: Cache expensive shortcode output using transients
- Test Responsiveness: Ensure shortcodes display correctly on all devices
- Document IDs: Keep track of which layout IDs are used where
Related
- Gutenberg Block - Modern block-based approach
- Visual Editor - Create and manage layouts
- Settings Overview - Configure layout settings