Below, you’ll find a detailed guide on how to add the Gs Pinterest Portfolio Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Gs Pinterest Portfolio Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Gs Pinterest Portfolio Plugin and the shortcodes it provides:
"WordPress Pinterest Plugin – Make a Popup, User Profile, Masonry and Gallery Layout is a user-friendly tool that lets you integrate Pinterest features into your WordPress site. Create a dynamic portfolio with ease using the gs-pinterest-portfolio plugin."
- [gs_pinterest]
- [gs_pin_widget]
- [gs_follow_pin_widget]
Gs Pinterest Portfolio [gs_pinterest] Shortcode
The gs-pinterest-portfolio plugin shortcode is designed to display Pinterest pins on your WordPress site. It fetches pins from a specified user’s Pinterest board and displays them in a customizable layout. The shortcode also ensures responsiveness across devices by adjusting the column count for desktop, tablet, and mobile views. It checks if the specified user’s Pinterest username is valid and handles errors gracefully. The shortcode supports different themes and generates inline CSS for custom styling. This shortcode also includes an asset generator and loader to optimize performance. If the assets are not found, it forces the assets to load for the first time and generates them for later use. If the assets are found, it stops forcing the load and leaves the job for the Asset Loader. In the end, the shortcode generates an output string that contains the HTML structure of the Pinterest pins and returns it. The shortcode also enqueues necessary assets and triggers a reprocess event to ensure the pins are displayed correctly on the page.
Shortcode: [gs_pinterest]
Parameters
Here is a list of all possible gs_pinterest shortcode parameters and attributes:
id
– Unique identifier for the shortcodepreview
– Determines if the shortcode is in preview modeuserid
– The Pinterest user IDboard_name
– The name of the Pinterest boardcount
– The number of Pinterest pins to displaycolumns
– Number of columns in the desktop viewcolumns_tablet
– Number of columns in the tablet viewcolumns_mobile_portrait
– Number of columns in the mobile portrait viewcolumns_mobile
– Number of columns in the mobile viewgutter
– The spacing between Pinterest pinslink_target
– Determines where the Pinterest pin links opentheme
– The theme of the Pinterest display
Examples and Usage
Basic example – Displaying a Pinterest portfolio using shortcode by referencing the unique ID.
[gs_pinterest id=1 /]
Advanced examples
Displaying a Pinterest portfolio with a specified theme and preview option. If the theme is not found, it will default to the standard layout. The preview attribute allows you to view the portfolio before publishing.
[gs_pinterest id=1 theme='gs_pin_theme1' preview=true /]
Displaying a Pinterest portfolio with a specific number of columns for different devices. This example shows how to set the number of columns for desktop, tablet, and mobile devices respectively.
[gs_pinterest id=1 columns=3 columns_tablet=2 columns_mobile=1 /]
Displaying a Pinterest portfolio with a specific gutter size and link target. The gutter size can be adjusted to increase or decrease the space between the pins. The link target attribute allows you to specify where the pin links will open.
[gs_pinterest id=1 gutter=10 link_target='_blank' /]
Displaying a Pinterest portfolio by referencing the user’s Pinterest username and specific board name. If the username or board name is invalid or not found, an error message will be returned.
[gs_pinterest id=1 userid='pinterestusername' board_name='boardname' /]
PHP Function Code
In case you have difficulties debugging what causing issues with [gs_pinterest]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gs_pinterest', array( $this, 'pinterestShortcode' ) );
Shortcode PHP function:
function pinterestShortcode( $atts ) {
$is_preview = !empty($atts['preview']);
if ( empty($atts['id']) ) {
return __( 'No shortcode ID found', 'gs-pinterest' );
}
$settings = (array) $this->gspinterest_get_temp_settings( $atts['id'], $is_preview ) ?? [];
if ( empty($settings) ) return __( 'No shortcode ID found', 'gs-pinterest' );
$settings['id'] = $atts['id'];
$settings['is_preview'] = $is_preview;
// By default force mode
$force_asset_load = true;
if ( ! $is_preview ) {
// For Asset Generator
$main_post_id = gsPinterestGenerator()->get_current_page_id();
$asset_data = gsPinterestGenerator()->get_assets_data( $main_post_id );
if ( empty($asset_data) ) {
// Saved assets not found
// Force load the assets for first time load
// Generate the assets for later use
gsPinterestGenerator()->generate( $main_post_id, $settings );
} else {
// Saved assets found
// Stop force loading the assets
// Leave the job for Asset Loader
$force_asset_load = false;
}
}
// responsive
$desktop = ! empty( $settings['shortcode_settings']['columns'] ) ? $settings['shortcode_settings']['columns'] : ( ($settings['shortcode_settings']['cols']) ?? 3 );
$tablet = ! empty( $settings['shortcode_settings']['columns_tablet'] ) ? $settings['shortcode_settings']['columns_tablet'] : ( ($settings['shortcode_settings']['cols']) ?? 2 );
$mobile_portrait = ! empty( $settings['shortcode_settings']['columns_mobile_portrait'] ) ? $settings['shortcode_settings']['columns_mobile_portrait'] : ( ($settings['shortcode_settings']['cols']) ?? 2 );
$columns_mobile = ! empty( $settings['shortcode_settings']['columns_mobile'] ) ? $settings['shortcode_settings']['columns_mobile'] : ( ($settings['shortcode_settings']['cols']) ?? 1 );
$columnClasses = gspin()->helpers->getColumnClasses( $desktop, $tablet, $mobile_portrait, $columns_mobile );
$fields = [ 'id', 'description', 'images' ];
$gutter = ! empty( $settings['shortcode_settings']['gutter'] ) ? $settings['shortcode_settings']['gutter'] : 10;
$link_target = ! empty( $settings['shortcode_settings']['link_target'] ) ? $settings['shortcode_settings']['link_target'] : '_blank';
$gs_rss_pins = [];
if ( empty( $settings['userid'] ) ) {
return esc_attr__( 'Pinterest username is invalid or empty', 'gs-pinterest' );
}
if ( 'gs_pin_theme6' !== $settings['shortcode_settings']['theme'] ) {
$pinterestBoards = new \GSPIN\Pinterest();
$gs_rss_pins = $pinterestBoards->getBoardPinsByUser( $settings['userid'], $settings['board_name'], $settings['count'], $fields );
}
$output = '';
$output .= sprintf( '<div class="gs_pin_area %s" data-gutter="%s">', $settings['shortcode_settings']['theme'], $settings['shortcode_settings']['gutter'] );
if( $settings['shortcode_settings']['theme'] === 'gs_pin_theme1' ) {
$template = 'gs_pinterest_structure_one.php';
}
if( $settings['shortcode_settings']['theme'] === 'gs_pin_theme_two' ) {
$template = 'gs_pinterest_structure_two_free.php';
}
if ( gspin()->helpers->isProActive() ) {
if ( 'gs_pin_theme2' === $settings['shortcode_settings']['theme'] ) {
$template = 'gs_pinterest_structure_two.php';
}
if ( 'gs_pin_theme3' === $settings['shortcode_settings']['theme'] ) {
$template = 'gs_pinterest_structure_three_hov.php';
}
if ( 'gs_pin_theme4' === $settings['shortcode_settings']['theme'] ) {
$template = 'gs_pinterest_structure_four_pop.php';
}
if ( 'gs_pin_theme5' === $settings['shortcode_settings']['theme'] ) {
$template = 'gs_pinterest_structure_five_grey.php';
}
if ( 'gs_pin_theme6' === $settings['shortcode_settings']['theme'] ) {
$template = 'gs_pinterest_user_profile.php';
}
}
include TemplateLoader::locate_template( $template );
$output .= gspin()->helpers->generateStyles( $settings['shortcode_settings']['gutter'] );
$output .= '</div>';
if ( $this->should_custom_script_render() || $force_asset_load ) :
gsPinterestGenerator()->force_enqueue_assets( $settings );
wp_add_inline_script( 'gs_pinterest_public', "jQuery(document).trigger( 'gspin:scripts:reprocess' );jQuery(function() { jQuery(document).trigger( 'gspin:scripts:reprocess' ) })" );
?>
<?php endif;
return $output;
}
Code file location:
gs-pinterest-portfolio/gs-pinterest-portfolio/includes/Shortcodes.php
Gs Pinterest Portfolio [gs_pin_widget] Shortcode
The GS Pinterest Portfolio plugin shortcode ‘gs_pin_widget’ allows you to embed a Pinterest pin on your page. The shortcode takes two parameters; ‘pin_link’ and ‘pin_width’. ‘pin_link’ is the URL of the Pinterest pin you wish to embed, and ‘pin_width’ determines the width of the embedded pin. This shortcode enables easy customization of Pinterest pins on your site.
Shortcode: [gs_pin_widget]
Parameters
Here is a list of all possible gs_pin_widget shortcode parameters and attributes:
pin_link
– The URL of the Pinterest pin to be displayedpin_width
– Controls the width of the Pinterest pin on the page
Examples and Usage
Basic example – Embeds a Pinterest pin on your WordPress site using the specified pin link and pin width.
[gs_pin_widget pin_link="https://www.pinterest.com/pin/377246906274938783/" pin_width="medium"]
Advanced examples – In this example, we are using the shortcode to display multiple Pinterest pins with varying widths. This can be useful if you want to showcase a variety of pins with different dimensions on your site.
[gs_pin_widget pin_link="https://www.pinterest.com/pin/377246906274938783/" pin_width="medium"]
[gs_pin_widget pin_link="https://www.pinterest.com/pin/377246906274938784/" pin_width="large"]
[gs_pin_widget pin_link="https://www.pinterest.com/pin/377246906274938785/" pin_width="small"]
PHP Function Code
In case you have difficulties debugging what causing issues with [gs_pin_widget]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gs_pin_widget', array( $this, 'pinWidget' ) );
Shortcode PHP function:
function pinWidget( $atts ) {
$atts = shortcode_atts(
array(
'pin_link' => '',
'pin_width' => ''
),
$atts
);
$output = '';
$output .= '<div class="pin-widget-area">';
$output .= '<a data-pin-do="embedPin" data-pin-width="'. $atts['pin_width'] .'" href="'. $atts['pin_link'] .'"></a>';
$output .= '</div>';
return $output;
}
Code file location:
gs-pinterest-portfolio/gs-pinterest-portfolio/includes/Shortcodes.php
Gs Pinterest Portfolio [gs_follow_pin_widget] Shortcode
The gs-pinterest-portfolio plugin shortcode ‘gs_follow_pin_widget’ creates a Pinterest follow button. This button links to a specified Pinterest user’s page. The shortcode accepts two parameters, ‘pin_user’ and ‘follow_lebel’. ‘pin_user’ is the Pinterest username and ‘follow_lebel’ is the text displayed on the follow button.
Shortcode: [gs_follow_pin_widget]
Parameters
Here is a list of all possible gs_follow_pin_widget shortcode parameters and attributes:
pin_user
– The username of the Pinterest accountfollow_lebel
– The text displayed on the follow button
Examples and Usage
Basic Example: – The basic usage of the gs-pinterest-portfolio plugin shortcode allows you to create a follow button for a specific Pinterest user. The ‘pin_user’ attribute is used to specify the Pinterest user, and ‘follow_lebel’ attribute is used to customize the follow button label.
[gs_follow_pin_widget pin_user="pinterestuser" follow_lebel="Follow me on Pinterest"]
Advanced Examples: – In more complex scenarios, you can use the same shortcode with different parameters to create multiple follow buttons for different Pinterest users on the same page. Each button can have a unique label, allowing you to customize the call to action for each user.
[gs_follow_pin_widget pin_user="pinterestuser1" follow_lebel="Follow User1"]
[gs_follow_pin_widget pin_user="pinterestuser2" follow_lebel="Follow User2"]
[gs_follow_pin_widget pin_user="pinterestuser3" follow_lebel="Follow User3"]
Remember that each shortcode should be placed in a separate paragraph or text block for proper formatting and functionality.
PHP Function Code
In case you have difficulties debugging what causing issues with [gs_follow_pin_widget]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gs_follow_pin_widget', array( $this, 'followPinShortcodeWidget' ) );
Shortcode PHP function:
function followPinShortcodeWidget( $atts ) {
$atts = shortcode_atts(
array(
'pin_user' => '',
'follow_lebel' => ''
),
$atts
);
$output = '';
$output .= '<div class="pin-follow-widget-area">';
$output .= sprintf(
'<a data-pin-do="buttonFollow" href="https://www.pinterest.com/%s/">%s</a>',
$atts['pin_user'], $atts['follow_lebel']
);
$output .= '</div>';
return $output;
}
Code file location:
gs-pinterest-portfolio/gs-pinterest-portfolio/includes/Shortcodes.php
Conclusion
Now that you’ve learned how to embed the Gs Pinterest Portfolio Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply