latest version

Portfolio

The Portfolio extension allows you to create Portfolio section on your site.

Configuration

In the config.php file, you can set the portfolio Gallery and Featured Image sizes.

$cfg['image_sizes'] = array(
    'featured-image' => array(
        'width'  => 227,
        'height' => 142,
        'crop'   => true
    ),
    'gallery-image'  => array(
        'width'  => 474,
        'height' => 241,
        'crop'   => true
    )
);

Also define if the portfolio custom post will support gallery or not.

$cfg['has-gallery'] = true;

Helpers

  • fw_ext_portfolio_get_gallery_images( $post_id ) - use this function to return all project gallery images.

    <?php if ( have_posts() ) : ?>
        <?php while ( have_posts() ) : ?>
            <?php $gallery = fw_ext_portfolio_get_gallery_images(); ?>
            <ul class="gallery">
                <?php foreach( $gallery as $image ) : ?>
                    <li>
                        <a href="<?php echo get_permalink($image['attachment_id'])?>">
                            <img src="<?php echo $image['url'] ?>" alt=""/>
                        </a>
                    </li>
                <?php endforeach ?>
            </ul>
        <?php endwhile ?>
    <?php endif ?>
    

    Note

    If you are in The Loop, the global $post will be used for $post_id

Hooks

  • fw_ext_portfolio_post_slug - portfolio custom post slug

    /**
     * @internal
     */
    function _filter_custom_portfolio_post_slug($slug) {
        return 'work';
    }
    add_filter('fw_ext_portfolio_post_slug', '_filter_custom_portfolio_post_slug');
    
  • fw_ext_portfolio_taxonomy_slug - portfolio taxonomy slug

    /**
     * @internal
     */
    function _filter_custom_portfolio_tax_slug($slug) {
        return 'works';
    }
    add_filter('fw_ext_portfolio_taxonomy_slug', '_filter_custom_portfolio_tax_slug');
    
  • fw_ext_projects_post_type_name - portfolio custom post labels (plural and singular)

    /**
     * @internal
     */
    function _filter_portfolio_labels($labels) {
        $labels = array(
            'singular' => __('Custom Project', '{domain}'),
            'plural'   => __('Custom Projects', '{domain}'),
        );
    
        return $labels;
    }
    add_filter('fw_ext_projects_post_type_name', '_filter_portfolio_labels');
    
  • fw_ext_portfolio_category_name - portfolio taxonomy labels (plural and singular)

    /**
     * @internal
     */
    function portfolio_tax_labels_names( $labels ) {
        $labels = array(
            'singular' => __( 'Custom Category', '{domain}' ),
            'plural'   => __( 'Custom Categories', '{domain}' ),
        );
    
        return $labels;
    }
    add_filter( 'fw_ext_portfolio_category_name', 'portfolio_tax_labels_names' );
    

Views



Templates are located in the views/ directory. Here is the list of templates that you can customize:

  • single.php - Portfolio course single post template. By default is used single.php from the theme root directory, you can overwrite it by creating framework-customizations/extensions/portfolio/views/single.php.
  • taxonomy.php - Portfolio category template. By default is used taxonomy.php from the theme root directory, you can overwrite it by creating framework-customizations/extensions/portfolio/views/taxonomy.php.
  • content.php - Default portfolio single page template content. It is loaded if the framework-customizations/extensions/portfolio/views/single.php doesn’t exist and is used single.php from the theme root directory. The content of this view is rendered using worpdress the_content filter, when the course single page is loaded.