Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Portfolio shortcode

Open pear1 opened this issue 11 years ago • 7 comments

Hello,

We are wondering how to create portfolio shortcode, because using documentation function fw_ext_portfolio_get_gallery_images() nothing happens inside shortcode.

And how to set WP Editor option to Visual by default, because for us it's ok, but most clients won't understand bb codes.

pear1 avatar Jun 02 '15 10:06 pear1

Hi,

  • Could you show me the entire shortcode structure, so I could see the problem?
  • Do you want to have page builder available on portfolio custom post, but the Visual Builder to be set by default? At the moment this is not possible, but we will make it possible in the next update

GheorgheP avatar Jun 04 '15 07:06 GheorgheP

Fixed the issue with Page Builder, now the developers will be able whenever the page builder is default editor or not by using the fw_page_builder_set_as_default filter.

GheorgheP avatar Jun 04 '15 07:06 GheorgheP

Thank you. In portfolio shortcode view.php file, we wanted to use something like this, which was taken from documentation:

<?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>

But looks like fw_ext_portfolio_get_gallery_images function works only inside portfolio page, in other pages this function isn't available.

Basically we just want to get portfolio information with categories and place it in front page with shortcode.

pear1 avatar Jun 04 '15 09:06 pear1

Did you inspect the fw_ext_portfolio_get_gallery_images(), it accepts the parameter $post_id. It can be used without parameter only in The Loop. When you use this function in shortcode, send the post ID as parameter.

/**
 * Returns portfolio project gallery images
 *
 * @param int $post_id
 *
 * @return array|null
 */
function fw_ext_portfolio_get_gallery_images( $post_id = 0 ) {
    if ( 0 === $post_id || null === ( $post_id = get_the_ID() ) ) {
        return array();
    }

    return fw_get_db_post_option($post_id, 'project-gallery', array());
}

GheorgheP avatar Jun 04 '15 11:06 GheorgheP

Sorry, I thought that it will happen automatically.

Then to use this function anywhere I want, I need to create a custom WP_query with fw-portfolio post type and then use this function inside that query loop?

pear1 avatar Jun 04 '15 12:06 pear1

In case you want to list all projects galleries, then is. In case you need a specific project, put the project id in the function as parameter.

GheorgheP avatar Jun 04 '15 12:06 GheorgheP

Yes, I need to display all projects galleries. Thank you for your help.

pear1 avatar Jun 04 '15 12:06 pear1