Schema & Structured Data for WP & AMP Shortcodes

Below, you’ll find a detailed guide on how to add the Schema & Structured Data for WP & AMP 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 Schema & Structured Data for WP & AMP Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Schema & Structured Data for WP & AMP Plugin and the shortcodes it provides:

Plugin Icon
Schema & Structured Data for WP & AMP

"Schema & Structured Data for WP & AMP is a powerful plugin designed to help enhance your website's SEO by adding schema markup. It's compatible with both WordPress and AMP."

★★★★☆ (230) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 5.6.20
Included Shortcodes:
  • [saswp-review]
  • [saswp-reviews-collection]
  • [saswp-reviews-form]
  • [saswp-reviews]
  • [saswp_tiny_howto]
  • [saswp_tiny_multiple_faq]
  • [saswp_tiny_faq]
  • [saswp_tiny_recipe]
  • [saswp-breadcrumbs]
  • [saswp-location]

[saswp-review] Shortcode

The SASWP Review shortcode is a powerful tool within the Schema and Structured Data for WP plugin. It displays review content on your website. The shortcode works by calling the ‘saswp_review_display_via_shortcode’ function. This function retrieves the review content associated with a specific ID, and returns it for display.

Shortcode: [saswp-review]

Parameters

Here is a list of all possible saswp-review shortcode parameters and attributes:

  • id – unique identifier for the specific review to display

Examples and Usage

Basic example – A fundamental usage of the shortcode to display a review by referencing its ID.

[saswp-review id=1 /]

Advanced examples

Using the shortcode to display multiple reviews by referencing their IDs. The reviews will load in the order of the IDs provided.

[saswp-review id="1,2,3,4" /]

Using the shortcode to display a review with additional parameters. In this example, the ‘style’ parameter is used to apply a specific style to the review display.

[saswp-review id=1 style="modern" /]

Please note, the ‘style’ parameter and multiple ID functionality are hypothetical and would require additional code in the PHP function to work as described.

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-review] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('saswp-review', array($this,'saswp_review_display_via_shortcode'));

Shortcode PHP function:

function saswp_review_display_via_shortcode($attr){
            
            $review_id = $attr['id'];
            
            if(isset($review_id)){
                
              $result = $this->saswp_get_review_box_content();  
              return $result;
              
            }
            
        }

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/rating-box/frontend.php

[saswp-reviews-collection] Shortcode

The ‘saswp-reviews-collection’ shortcode from the Schema and Structured Data for WP & AMP plugin generates a collection of reviews. It pulls reviews from a specified platform, sorts them, and displays them in a customizable format. . The shortcode uses various parameters to modify the output. These include design, date format, image visibility, and color options. It also supports pagination and auto-sliding for gallery design.

Shortcode: [saswp-reviews-collection]

Parameters

Here is a list of all possible saswp-reviews-collection shortcode parameters and attributes:

  • id – A unique identifier for the specific review collection

Examples and Usage

Basic example – Show reviews collection by referencing the ID of the collection.

[saswp-reviews-collection id=1 /]

Advanced examples

Displaying reviews collection by referencing the ID and setting the admin status. This will first try to load by ID, but if not found, it will check the admin status.

[saswp-reviews-collection id=1 is_admin=true /]

Using the shortcode to display a reviews collection by referencing both ID and setting the number of reviews per page. This will first try to load by ID, but if not found, it will set the number of reviews per page.

[saswp-reviews-collection id=1 perpage=10 /]

Using the shortcode to display a reviews collection by referencing both ID and setting the sorting order. This will first try to load by ID, but if not found, it will set the sorting order of the reviews.

[saswp-reviews-collection id=1 sorting="desc" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-reviews-collection] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp-reviews-collection', array($this, 'saswp_reviews_collection_shortcode_render' ),10);

Shortcode PHP function:

function saswp_reviews_collection_shortcode_render($attr){
            
            global $saswp_post_reviews, $collection_aggregate;
            
            $html = $htmlp = '';
            
            if(!is_admin()){
                
                if(isset($attr['id'])){
                    $collection_post_status = get_post_status($attr['id']);
                    if($collection_post_status == 'publish'){
                        $total_reviews        = array();                 
                        $total_reviews_count  = 0;
                        $collection           = array();                  
                        $platform_id          = array();
                        $pagination           = null;
                        $pagination_wpr       = null;
                        $perpage              = null;
                        $data_id              = null;
                        $dots = $f_interval = $f_visibility = $arrow = 1;
                        $g_type = $design = $cols = $sorting = $date_format = $collection_review_imag = '';
                        $stars_color = ''; $g_interval = 3000; $auto_slider = 0;
                        $collection_data = get_post_meta($attr['id']);
                        
                        if(isset($collection_data['saswp_collection_design'][0])){
                            $design        = $collection_data['saswp_collection_design'][0];
                            $this->_design = $design;
                        }

                        if(isset($collection_data['saswp_collection_date_format'][0])){
                            $date_format        = $collection_data['saswp_collection_date_format'][0];                    
                        } 
                        if(isset($collection_data['saswp_collection_hide_col_r_img'][0])){
                            $saswp_collection_hide_col_rew_img   = $collection_data['saswp_collection_hide_col_r_img'][0];                    
                        }else{
                            $saswp_collection_hide_col_rew_img   = "";
                        } 
                        if(isset($collection_data['saswp_collection_gallery_img_hide'][0])){
                            $saswp_collection_gallery_img_hide        = $collection_data['saswp_collection_gallery_img_hide'][0];                    
                        }else{
                            $saswp_collection_gallery_img_hide  = "";
                        }      
                        
                        if(isset($collection_data['saswp_collection_cols'][0])){
                            
                            $cols          = $collection_data['saswp_collection_cols'][0];
                        }
                        
                        if(isset($collection_data['saswp_collection_cols'][0])){
                            
                            $cols          = $collection_data['saswp_collection_cols'][0];
                        }

                        if(isset($collection_data['saswp_stars_color_picker'][0])  && !empty($collection_data['saswp_stars_color_picker'][0])){
                            
                            $stars_color   = $collection_data['saswp_stars_color_picker'][0];
                        }
                       
                        if(isset($collection_data['saswp_gallery_arrow'][0])){
                            
                            $arrow        = $collection_data['saswp_gallery_arrow'][0];
                        }
                                        
                        if(isset($collection_data['saswp_gallery_dots'][0])){
                            $dots         = $collection_data['saswp_gallery_dots'][0];
                        }
                                    
                        if(isset($collection_data['saswp_collection_gallery_type'][0])){
                            $g_type       = $collection_data['saswp_collection_gallery_type'][0];
                        }

                        if(isset($collection_data['saswp_collection_gallery_interval'][0])){
                            $g_interval       = $collection_data['saswp_collection_gallery_interval'][0];
                        }
                        if(isset($collection_data['saswp_gallery_slide_auto'][0])){
                            $auto_slider       = $collection_data['saswp_gallery_slide_auto'][0];
                        }
                        
                        if(isset($collection_data['saswp_fomo_interval'][0])){
                            $f_interval   = $collection_data['saswp_fomo_interval'][0];
                        }
                        
                        if(isset($collection_data['saswp_fomo_visibility'][0])){
                            $f_visibility = $collection_data['saswp_fomo_visibility'][0];
                        }
                                        
                        if(isset($collection_data['saswp_collection_sorting'][0])){
                            $sorting      = $collection_data['saswp_collection_sorting'][0];                
                        }
                        
                        if(isset($collection_data['saswp_platform_ids'][0])){
                            $platform_id  = unserialize($collection_data['saswp_platform_ids'][0]);                
                        }

                        
                        if(isset($collection_data['saswp_platform_ids'][0])){
                            
                            $total_reviews  = unserialize($collection_data['saswp_total_reviews'][0]);
                            if( is_array($total_reviews) && !empty($total_reviews) ){
                                $total_reviews_count = count($total_reviews);
                            }
                            
                        }
                        if(isset($collection_data['saswp_collection_pagination'][0])){
                            $pagination  = $collection_data['saswp_collection_pagination'][0];                
                        }
                        if(isset($collection_data['saswp_collection_pagination_wpr'][0])){
                            $pagination_wpr  = $collection_data['saswp_collection_pagination_wpr'][0];                
                        }
                        if(isset($collection_data['saswp_platform_ids'][0])){
                            $perpage  = $collection_data['saswp_collection_per_page'][0];                
                        }
                        if(isset($collection_data['saswp_collection_image_thumbnail'][0]) && !empty($collection_data['saswp_collection_image_thumbnail'][0])){
                            $collection_review_imag  = $collection_data['saswp_collection_image_thumbnail'][0];                
                        }
                                                   
                    if($total_reviews){
                           
                            wp_enqueue_style( 'saswp-collection-front-css', SASWP_PLUGIN_URL . 'admin_section/css/'.(SASWP_ENVIRONMENT == 'production' ? 'collection-front.min.css' : 'collection-front.css'), false , SASWP_VERSION );
                            wp_enqueue_script( 'saswp-collection-front-js', SASWP_PLUGIN_URL . 'admin_section/js/'.(SASWP_ENVIRONMENT == 'production' ? 'collection-front.min.js' : 'collection-front.js'), array('jquery') , SASWP_VERSION );
                            
                            add_action( 'amp_post_template_css', array($this, 'saswp_reviews_collection_amp_css'));
                           
                            
                            if($design == 'grid'){
                               
                                $nextpage = $perpage;
                                $offset   = 0;

                                if($pagination && !$pagination_wpr){

                                    $data_id = 1; 
                                    
                                    if(isset($_GET['rv_page'])){
                                        $data_id = sanitize_text_field($_GET['rv_page']); 
                                    }
                                    
                                    if($data_id > 0){                        
                                        $nextpage            = $data_id * $perpage;                
                                    }                    
                                    $offset    = $nextpage - $perpage;
                                    
                                    $array_chunk = array_chunk($total_reviews,$perpage);                            
                                    $total_reviews = $array_chunk[($data_id-1)]; 

                                }
                           
                                if(!$collection_aggregate){

                                    $col_average = $this->_service->saswp_get_collection_average_rating(unserialize($collection_data['saswp_total_reviews'][0]));

                                    if($col_average){
                                        $collection_aggregate['count'] = $total_reviews_count;
                                        $collection_aggregate['average']  = $col_average;
                                    }
                                    
                                }
                                
                                
                            }
                            
                            $collection = $this->_service->saswp_get_reviews_list_by_design($design, $platform_id, $total_reviews, $sorting, $stars_color,$collection_review_imag);                    
                          
                               
                            if($design == 'badge'){

                                $new_coll = array();

                                if($collection){
                                    foreach($collection as $coll){
                                        foreach($coll as $new){
                                            $new_coll[] = $new;   
                                        }
                                    }
                                }
                                
                                $saswp_post_reviews = array_merge($saswp_post_reviews, $new_coll);
                            }else{
                                $saswp_post_reviews = array_merge($saswp_post_reviews, $collection);
                            }
                            if(empty($saswp_post_reviews) || isset($saswp_post_reviews)){
                                $saswp_post_reviews = array();
                            }
                                                
                            switch($design) {
                                
                                case "grid":
                                   
                                    $html = $this->_service->saswp_create_collection_grid($cols, $collection, $total_reviews, $pagination, $perpage, $offset, $nextpage, $data_id, $total_reviews_count, $date_format, $pagination_wpr, $saswp_collection_hide_col_rew_img,$stars_color);
                                    
                                    break;
                                    
                                case 'gallery':
                                    
                                    $html = $this->_service->saswp_create_collection_slider($g_type, $arrow, $dots, $collection, $date_format, $saswp_collection_gallery_img_hide,$stars_color,$g_interval,$auto_slider);
                                    
                                    break;
                                
                                case 'badge':
                               
                                    $html = $this->_service->saswp_create_collection_badge($collection, $saswp_collection_hide_col_rew_img,$stars_color);
                                    
                                    break;
                                    
                                case 'popup':
                                   
                                    $html = $this->_service->saswp_create_collection_popup($collection, $date_format, $saswp_collection_hide_col_rew_img,$stars_color);
                                    
                                    break;
                                
                                case 'fomo':
                                    
                                    $html = $this->_service->saswp_create_collection_fomo($f_interval, $f_visibility, $collection, $date_format, $saswp_collection_hide_col_rew_img,$stars_color);                   
                                    
                                    break;
                                                                            
                            }                       
                        }                              
                    }
                }
                $htmlp .= '<div class="saswp-r">';
                $htmlp .= $html;  
                $htmlp .= '</div>';                    
            }
            
            return $htmlp;           
        }

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/reviews/reviews_collection.php

[saswp-reviews-form] Shortcode

The ‘saswp-reviews-form’ shortcode from the Schema and Structured Data for WP plugin is used to generate a review form. It accepts attributes such as site_key, secret_key, and onbutton. The form includes fields for reviewer name, review text, and a rating system. It also integrates Google’s reCAPTCHA for spam protection.

Shortcode: [saswp-reviews-form]

Parameters

Here is a list of all possible saswp-reviews-form shortcode parameters and attributes:

  • site_key – Site key for Google reCAPTCHA integration
  • secret_key – Secret key for Google reCAPTCHA integration
  • onbutton – Determines if the review form is triggered by a button

Examples and Usage

Basic example: – Display the review form using the ‘saswp-reviews-form’ shortcode. This will render a review form on the page where you place the shortcode.

[saswp-reviews-form /]

Advanced examples:

Display the review form with Google reCAPTCHA by providing ‘site_key’ and ‘secret_key’ attributes. Replace ‘your_site_key’ and ‘your_secret_key’ with your actual reCAPTCHA keys. This will add an extra layer of security to your form against spam and abuse.

[saswp-reviews-form site_key="your_site_key" secret_key="your_secret_key" /]

Show the review form on a button click by specifying the ‘onbutton’ attribute. When the user clicks the button, the review form will appear.

[saswp-reviews-form onbutton="true" /]

Combination of both advanced examples: Display the review form with Google reCAPTCHA and on a button click.

[saswp-reviews-form site_key="your_site_key" secret_key="your_secret_key" onbutton="true" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-reviews-form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp-reviews-form', array($this, 'saswp_reviews_form_render' ));

Shortcode PHP function:

function saswp_reviews_form_render($attr){
            
            $on_button = false;
            
            update_option('saswp_g_site_key', '');
            update_option('saswp_g_secret_key', '');

            if(isset($attr['site_key'])){
                update_option('saswp_g_site_key', sanitize_text_field($attr['site_key']));
            }
            if(isset($attr['secret_key'])){
                update_option('saswp_g_secret_key', sanitize_text_field($attr['secret_key']));
            }
            
            if(isset($attr['onbutton'])){
                $on_button = true;
            }
            
            $is_amp = false;
            
            if(!saswp_non_amp()){
                $is_amp = true;
            }
            add_action( 'amp_post_template_css', array($this, 'saswp_review_form_amp_css'));
            
            ob_start();
            
            global $post;
            global $wp;
           
            $localize = array(
                'is_rtl'                       => is_rtl()
            );


            wp_register_script( 'saswp-review-form-js', SASWP_PLUGIN_URL . 'admin_section/js/'.(SASWP_ENVIRONMENT == 'production' ? 'review-form.min.js' : 'review-form.js'), array('jquery', 'jquery-ui-core'), SASWP_VERSION );

            wp_localize_script( 'saswp-review-form-js', 'saswp_localize_review_data', $localize );
        
            wp_enqueue_script( 'saswp-review-form-js' );

            wp_enqueue_script( 'saswp-rateyo-front-js', SASWP_PLUGIN_URL . 'admin_section/js/jquery.rateyo.min.js', array('jquery', 'jquery-ui-core'), SASWP_VERSION , true );                                                                                        
            wp_enqueue_style(  'saswp-review-form-css', SASWP_PLUGIN_URL . 'admin_section/css/'.(SASWP_ENVIRONMENT == 'production' ? 'review-form.min.css' : 'review-form.css'), false, SASWP_VERSION );
            wp_enqueue_style(  'jquery-rateyo-min-css', SASWP_PLUGIN_URL . 'admin_section/css/'.(SASWP_ENVIRONMENT == 'production' ? 'jquery.rateyo.min.css' : 'jquery.rateyo.min.css'), false, SASWP_VERSION );
            
            if( isset($attr['site_key']) && isset($attr['secret_key']) ){
                wp_enqueue_script( 'saswp-recaptcha', 'https://www.google.com/recaptcha/api.js'); 
            }

            $form = $current_url = '';
            
            if(is_object($wp)){
                $current_url = home_url( add_query_arg( array(), $wp->request ) );
            }
            
            $form       .= '<div class="saswp-rv-form-container">';
            
            if(!$is_amp){ 
                
                if($on_button){
                    $form       .= '<div class="saswp-rv-form-btn"><a href="#" class="button button-default">'.saswp_t_string(saswp_label_text('translation-review-form')).'</a></div>';
                }
                
                $rating_html = '<div class="saswp-rating-container"><div class="saswp-rating-front-div"></div><div class="saswp-rateyo-counter"></div><input type="hidden" name="saswp_review_rating" value="5"></div>';
                $form   .= '<form action="'.esc_url( admin_url('admin-post.php') ).'" method="post" class="saswp-review-submission-form '.($on_button ? "saswp_hide" : "").'">';
                
            }else{
                
                add_action( 'amp_post_template_data', array($this, 'saswp_reviews_form_amp_script'));  
                
                if($on_button){
                    $form       .= '<div class="saswp-rv-form-btn"><a href="#" class="button button-default" on="tap:AMP.setState({ saswp_review_form_toggle: !saswp_review_form_toggle })" role="button" tabindex="1">'.saswp_t_string(saswp_label_text('translation-review-form')).'</a></div>';
                }
                
                $form   .= '<form   action-xhr="'.esc_url( admin_url('admin-post.php') ).'" method="post" class="saswp-review-submission-form '.($on_button ? "saswp_hide" : "").'" [class]="saswp_review_form_toggle ? \'saswp-review-submission-form\' : \'saswp_hide saswp-review-submission-form\' ">';
                
                $rating_html = ''
                        . '<input type="hidden" name="saswp_review_rating" [value]="saswp_review_rating">'
                        . '<div class="saswp-rvw-str">'
                        . '<span [class]="saswp_review_rating >= 1 ? \'str-ic\' : \'df-clr\' " class="df-clr" on="tap:AMP.setState({ saswp_review_rating: 1 })" role="button" tabindex="1"></span>'
                        . '<span [class]="saswp_review_rating >= 2 ? \'str-ic\' : \'df-clr\' " class="df-clr" on="tap:AMP.setState({ saswp_review_rating: 2 })" role="button" tabindex="2"></span>'
                        . '<span [class]="saswp_review_rating >= 3 ? \'str-ic\' : \'df-clr\' " class="df-clr" on="tap:AMP.setState({ saswp_review_rating: 3 })" role="button" tabindex="3"></span>'
                        . '<span [class]="saswp_review_rating >= 4 ? \'str-ic\' : \'df-clr\' " class="df-clr" on="tap:AMP.setState({ saswp_review_rating: 4 })" role="button" tabindex="4"></span>'
                        . '<span [class]="saswp_review_rating >= 5 ? \'str-ic\' : \'df-clr\' " class="df-clr" on="tap:AMP.setState({ saswp_review_rating: 5 })" role="button" tabindex="5"></span>'
                        . '</div>';
                                
            }
            
            $form   .= wp_nonce_field( 'saswp_review_form', 'saswp_review_nonce' )

                    . '<div class="saswp-form-tbl">'
                    
                    . '<div class="saswp-form-fld">'
                    .   '<span>'.saswp_t_string(saswp_label_text('translation-name')).'</span>'
                    .   '<input type="text" name="saswp_reviewer_name" required>'
                    . '</div>'

                    . '<div class="saswp-form-fld">'
                    .   '<span>'.saswp_t_string(saswp_label_text('translation-comment')).'</span>'
                    .   '<textarea name="saswp_review_text"></textarea>'
                    . '</div>'

                    . '<input type="hidden" name="saswp_review_link" value="'.esc_url($current_url).'">'
                    . $rating_html
                    . '<input type="hidden" name="saswp_place_id" value="'.esc_attr($post->ID).'">'
                    . '<input type="hidden" name="action" value="saswp_review_form">';
                    
                    if( isset($attr['site_key']) && isset($attr['secret_key']) ) {
                        $form.=    '<div class="g-recaptcha" data-sitekey="'.esc_attr($attr['site_key']).'"></div>';
                    }

                    $form.= '<input name="saswp-review-save" type="submit" class="submit">'                                        
                    . '</div>'
                    . '</form>'
                    . '</div>';
            
            
             echo $form;
             return ob_get_clean();
            
        }

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/reviews/reviews_form.php

[saswp-reviews] Shortcode

The ‘saswp-reviews’ shortcode from the Schema and Structured Data for WP plugin retrieves and displays reviews. This shortcode uses the ‘saswp_reviews_shortcode’ function to pull reviews based on given attributes. If reviews are found, they are merged with existing reviews and displayed using ‘saswp_reviews_html_markup’.

Shortcode: [saswp-reviews]

Examples and Usage

Basic example – Utilizing the shortcode to display reviews by specifying the ID.

[saswp-reviews id=1 /]

Advanced examples

Displaying reviews by referencing both ID and type. The reviews will first try to load by ID, but if not found, it will try to load by type.

[saswp-reviews id=1 type="product" /]

Displaying reviews by referencing both ID, type and limit. This will display a specific number of reviews based on the limit parameter.

[saswp-reviews id=1 type="product" limit=5 /]

Displaying reviews by referencing ID, type, limit and order. This will display a specific number of reviews based on the limit parameter and in the order specified.

[saswp-reviews id=1 type="product" limit=5 order="desc" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-reviews] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('saswp-reviews', array($this, 'saswp_reviews_shortcode' ),10);

Shortcode PHP function:

function saswp_reviews_shortcode($attr){
                            
        $response = '';
        
        $reviews = $this->saswp_get_reviews_list_by_parameters($attr);
        
        if($reviews){
               global $saswp_post_reviews;
               $saswp_post_reviews = array_merge($saswp_post_reviews, $reviews);    
               $response = $this->saswp_reviews_html_markup($reviews);                                                                                         
        }
                                           
        return $response;
        
    }

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/reviews/reviews_service.php

[saswp_tiny_howto] Shortcode

The ‘saswp_tiny_howto’ shortcode from the Schema and Structured Data for WP plugin is designed to render how-to guides. This shortcode allows users to specify various attributes such as cost, time, and steps involved in a how-to guide. It then generates a structured layout with these details. It also supports the inclusion of images for each step, providing a rich, detailed guide for users.

Shortcode: [saswp_tiny_howto]

Parameters

Here is a list of all possible saswp_tiny_howto shortcode parameters and attributes:

  • css_class – adds a custom CSS class to the shortcode output
  • count – specifies the number of elements to display
  • html – determines if the output should be in HTML format
  • cost – adds the cost associated with the how-to
  • cost_currency – specifies the currency of the cost
  • days – adds the number of days required for the how-to
  • hours – provides the number of hours needed for the how-to
  • minutes – states the number of minutes required for the how-to
  • description – adds a description to the how-to
  • elements – an array of elements for the how-to, each element can have a headline, step_title, step_description, and image

Examples and Usage

Basic example – Display a simple how-to guide with a single step.

[saswp_tiny_howto css_class="howto-guide" count="1" html="true" description="This is a simple guide" elements="{'step_title' : 'Step 1', 'step_description' : 'This is the first step'}" /]

Advanced examples

Display a how-to guide with cost, time required, and multiple steps. Also, add images to the steps.

[saswp_tiny_howto css_class="howto-guide" count="3" html="true" cost="50" cost_currency="USD" days="2" hours="5" minutes="30" description="This is an advanced guide" elements="{'step_title-1' : 'Step 1', 'step_description-1' : 'This is the first step', 'image-1' : 'image_url_1', 'step_title-2' : 'Step 2', 'step_description-2' : 'This is the second step', 'image-2' : 'image_url_2', 'step_title-3' : 'Step 3', 'step_description-3' : 'This is the third step', 'image-3' : 'image_url_3'}" /]

Display a how-to guide with cost and time required but without any steps.

[saswp_tiny_howto css_class="howto-guide" html="true" cost="100" cost_currency="EUR" days="3" hours="7" minutes="45" description="This is a guide without steps" /]

Display a how-to guide without cost but with time required and a single step.

[saswp_tiny_howto css_class="howto-guide" count="1" html="true" days="1" hours="2" minutes="15" description="This is a guide with time required" elements="{'step_title' : 'Step 1', 'step_description' : 'This is the first step'}" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp_tiny_howto] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp_tiny_howto', 'saswp_tiny_howto_render' );

Shortcode PHP function:

function saswp_tiny_howto_render( $atts, $content = null ){

    global $saswp_tiny_howto;

    $output = '';

    $saswp_tiny_howto = shortcode_atts(
        [
            'css_class'     => '',
            'count'         => '1',
            'html'          => true,
            'cost'          => '',
            'cost_currency' => '',
            'days'          => '',
            'hours'         => '',
            'minutes'       => '',
            'description'   => '',            
            'elements'      => [],
        ], $atts );

    foreach ( $atts as $key => $merged_att ) {
        if ( strpos( $key, 'headline' ) !== false || strpos( $key, 'step_title' ) !== false || strpos( $key,
                'step_description' ) !== false || strpos( $key, 'image' ) !== false ) {
            $saswp_tiny_howto['elements'][ explode( '-', $key )[1] ][ substr( $key, 0, strpos( $key, '-' ) ) ] = $merged_att;
        }
    }
    
    if($saswp_tiny_howto['html'] == 'true'){
                               
        if( !empty($saswp_tiny_howto['cost']) ){

            $time_html = '';
            $time_html .=   esc_attr($saswp_tiny_howto['cost']). ' ';

            if(!empty($saswp_tiny_howto['cost_currency'])){
                $time_html .=     esc_attr($saswp_tiny_howto['cost_currency']);
            }

            if($time_html !=''){
                $output .= '<p class="saswp-how-to-total-time">';
                $output .= '<span class="saswp-how-to-duration-time-text"><strong>'.saswp_label_text('translation-estimate-cost').' :</strong> </span>';    
                $output .= $time_html;
                $output .= '</p>';
            }

        }
        
        if( !empty($saswp_tiny_howto['days']) || !empty($saswp_tiny_howto['hours']) || !empty($saswp_tiny_howto['minutes']) ){

            $time_html = '';            

            if(!empty($saswp_tiny_howto['days'])){
                $time_html .=     esc_attr($saswp_tiny_howto['days']).' days ';
            }
            if(!empty($saswp_tiny_howto['hours'])){
                $time_html .=     esc_attr($saswp_tiny_howto['hours']).' hours ';
            }
            if(!empty($saswp_tiny_howto['minutes'])){
                $time_html .=     esc_attr($saswp_tiny_howto['minutes']).' minutes ';
            }

            if($time_html !=''){
                $output .= '<p class="saswp-how-to-total-time">';
                $output .= '<span class="saswp-how-to-duration-time-text"><strong>'.saswp_label_text('translation-time-needed').' :</strong> </span>';    
                $output .= $time_html;
                $output .= '</p>';
            }

        }

        if( !empty($saswp_tiny_howto['description']) ){
            $output .= '<p>'.html_entity_decode(esc_attr($saswp_tiny_howto['description'])).'</p>';
        }
        
        if( !empty($saswp_tiny_howto['elements']) ){

            $output .= '<div class="saswp-how-to-block-steps">';
            $output .= '<ol>';

            foreach ($saswp_tiny_howto['elements'] as $value) {
                
                if($value['step_title'] || $value['step_description']){
                    
                    $output .= '<li>'; 
                    $output .= '<strong class="saswp-how-to-step-name">'. html_entity_decode(esc_attr($value['step_title'])).'</strong>';
                    $output .= '<p class="saswp-how-to-step-text">'.html_entity_decode(esc_textarea($value['step_description']));

                    if ( ! empty( $value['image'] ) ) {
                    
                        $image_id       = intval( $value['image'] );                
                        $image_thumburl = wp_get_attachment_image_url( $image_id, [ 150, 150 ] );
                        
                        $output .= '<figure>';
                        $output .= '<a href="'.esc_url(esc_url($image_thumburl)).'"><img class="saswp_tiny_howto_image" src="'.esc_url($image_thumburl).'"></a>';
                        $output .= '</figure>';
    
                    }

                    $output .= '</p>';
                    $output .= '</li>';
                }  

            }
            $output .= '</ol>';
            $output .= '</div>';
            
        }

    }    

    return $output;
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/tinymce/register-shortcodes.php

[saswp_tiny_multiple_faq] Shortcode

The ‘saswp_tiny_multiple_faq’ shortcode from the Schema and Structured Data for WP plugin is designed to render multiple FAQs on a webpage. The shortcode allows you to specify attributes like the CSS class, count, HTML, and elements. It then loops through these attributes to generate a section for each FAQ. If an image is provided, it’s displayed alongside the FAQ. The output is a structured FAQ section that enhances SEO.

Shortcode: [saswp_tiny_multiple_faq]

Parameters

Here is a list of all possible saswp_tiny_multiple_faq shortcode parameters and attributes:

  • css_class – A custom CSS class to style the FAQ section
  • count – Number of FAQs to display. Default is ‘1’
  • html – If set to ‘true’, FAQ will be displayed in HTML format
  • elements – Array of FAQ elements including ‘headline’, ‘question’, ‘answer’, and ‘image’
  • headline – The headline of each FAQ
  • question – The question of each FAQ
  • answer – The answer of each FAQ
  • image – The image ID to be displayed with each FAQ

Examples and Usage

Basic example – A shortcode that renders a single FAQ section with a question and answer.

[saswp_tiny_multiple_faq css_class="faq_class" count="1" headline-1="h2" question-1="What is a shortcode?" answer-1="A shortcode is a WordPress-specific code that lets you do nifty things with very little effort."] 

Advanced examples

Using the shortcode to display multiple FAQ sections with questions, answers, and images. Each FAQ section is rendered with a different headline tag, question, answer, and image.

[saswp_tiny_multiple_faq css_class="faq_class" count="2" headline-1="h2" question-1="What is a shortcode?" answer-1="A shortcode is a WordPress-specific code that lets you do nifty things with very little effort." image-1="1" headline-2="h3" question-2="What is a plugin?" answer-2="A plugin is a piece of software containing a group of functions that can be added to a WordPress website." image-2="2"]

Using the shortcode to display a FAQ section with a question, answer, and image. The FAQ section is rendered with a specific CSS class.

[saswp_tiny_multiple_faq css_class="custom_faq_class" count="1" headline-1="h2" question-1="What is a shortcode?" answer-1="A shortcode is a WordPress-specific code that lets you do nifty things with very little effort." image-1="1"]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp_tiny_multiple_faq] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp_tiny_multiple_faq', 'saswp_tiny_multi_faq_render' );

Shortcode PHP function:

function saswp_tiny_multi_faq_render( $atts, $content = null ){

    global $saswp_tiny_multi_faq;

    $output = '';

    $saswp_tiny_multi_faq = shortcode_atts(
        [
            'css_class' => '',
            'count'     => '1',
            'html'      => true,
            'elements'  => [],
        ], $atts );

    foreach ( $atts as $key => $merged_att ) {
        if ( strpos( $key, 'headline' ) !== false || strpos( $key, 'question' ) !== false || strpos( $key,
                'answer' ) !== false || strpos( $key, 'image' ) !== false ) {
            $saswp_tiny_multi_faq['elements'][ explode( '-', $key )[1] ][ substr( $key, 0, strpos( $key, '-' ) ) ] = $merged_att;
        }
    }

    
    if($saswp_tiny_multi_faq['html'] == 'true'){

        if( !empty($saswp_tiny_multi_faq['elements']) ){

            foreach ($saswp_tiny_multi_faq['elements'] as $value) {
                
                $output .= '<section>';
                $output .= '<summary>';
                $output .= '<'.esc_attr($value['headline']).'>';
                $output .=  esc_html($value['question']);
                $output .= '</'.esc_attr($value['headline']).'>';
                $output .= '</summary>';

                $output .= '<div>';

                if ( ! empty( $value['image'] ) ) {
                    
                    $image_id       = intval( $value['image'] );                
                    $image_thumburl = wp_get_attachment_image_url( $image_id, [ 150, 150 ] );
                    
                    $output .= '<figure>';
                    $output .= '<a href="'.esc_url(esc_url($image_thumburl)).'"><img class="saswp_tiny_faq_image" src="'.esc_url($image_thumburl).'"></a>';
                    $output .= '</figure>';

                }
                
                $output .= '<div class="saswp_faq_tiny_content">'.esc_html($value['answer']).'</div>';
                
                $output .= '</div>';
                $output .= '</section>';

            }
            
        }

    }    

    return $output;
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/tinymce/register-shortcodes.php

[saswp_tiny_faq] Shortcode

The ‘saswp_tiny_faq’ shortcode from the Schema-and-Structured-Data-for-WP plugin is designed to render FAQs with an optional image. It uses attributes like headline, img, img_alt, question, answer, and html. If ‘html’ is set to true, it generates a summary with a headline and question, followed by an image (if provided) and the FAQ content.

Shortcode: [saswp_tiny_faq]

Parameters

Here is a list of all possible saswp_tiny_faq shortcode parameters and attributes:

  • headline – Specifies the HTML tag for the FAQ question.
  • img – The ID of the image to be displayed.
  • img_alt – The alt text for the image, for accessibility.
  • question – The text of the FAQ question to be displayed.
  • answer – The text of the FAQ answer to be displayed.
  • html – Determines if the content will be displayed in HTML format.

Examples and Usage

Basic example – The following shortcode displays a simple FAQ section with a question and answer, using the default headline tag (h2).

[saswp_tiny_faq question="What is structured data?" answer="Structured data is a standardized format for providing information about a page and classifying the page content."] 

Advanced examples

Here, the shortcode is used to display an FAQ section with a custom headline tag, an image, and alternate text for the image. It also uses custom HTML for the answer.

[saswp_tiny_faq headline="h3" img="123" img_alt="An image description" question="What is structured data?" answer="<p>Structured data is a standardized format for providing information about a page and classifying the page content.</p>"] 

In this next example, the shortcode is used to display an FAQ section without any HTML in the answer. The ‘html’ attribute is set to ‘false’ to achieve this.

[saswp_tiny_faq question="What is structured data?" answer="Structured data is a standardized format for providing information about a page and classifying the page content." html="false"] 

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp_tiny_faq] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp_tiny_faq', 'saswp_tiny_faq_render' );

Shortcode PHP function:

function saswp_tiny_faq_render( $atts, $content = null ){

        global $saswp_tiny_faq;

        $saswp_tiny_faq = shortcode_atts(
            [            
                'headline'  => 'h2',
                'img'       => 0,
                'img_alt'   => '',
                'question'  => '',
                'answer'    => '',
                'html'      => 'true',         
            ], $atts );
            
        $output = '';

        if($saswp_tiny_faq['html'] == 'true'){                        

            $output .= '<summary>';
            $output .= '<'.esc_attr($saswp_tiny_faq['headline']).'>';
            $output .=  esc_html($saswp_tiny_faq['question']);
            $output .= '</'.esc_attr($saswp_tiny_faq['headline']).'>';
            $output .= '</summary>';

            $output .= '<div>';

            if ( ! empty( $saswp_tiny_faq['img'] ) ) {
                
                $image_id       = intval( $saswp_tiny_faq['img'] );                
                $image_thumburl = wp_get_attachment_image_url( $image_id, [ 150, 150 ] );
                
                $output .= '<figure>';
                $output .= '<a href="'.esc_url(esc_url($image_thumburl)).'"><img class="saswp_tiny_faq_image" src="'.esc_url($image_thumburl).'"></a>';
                $output .= '</figure>';

            }
            
            $output .= '<div class="saswp_faq_tiny_content">'.esc_html($content).'</div>';
            
            $output .= '</div>';

        }    
                
        return $output;
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/tinymce/register-shortcodes.php

[saswp_tiny_recipe] Shortcode

The ‘Schema and Structured Data for WP’ plugin shortcode, ‘saswp_tiny_recipe’, is designed to render a styled recipe block on your website. This shortcode pulls in various attributes like recipe details, ingredients, directions, and notes. It checks for image availability and displays it. It also formats and presents the information in an organized, SEO-friendly manner.

Shortcode: [saswp_tiny_recipe]

Parameters

Here is a list of all possible saswp_tiny_recipe shortcode parameters and attributes:

  • recipe_by – Name of the person who made the recipe.
  • course – The type of dish (e.g., Breakfast, Lunch, Dinner).
  • cusine – The style or origin of the food (e.g., Italian, Chinese).
  • difficulty – The level of complexity to prepare the dish.
  • servings – The number of portions the recipe yields.
  • prepration_time – The time needed to prepare the ingredients.
  • cooking_time – The time needed to cook the dish.
  • calories – The number of calories the dish contains.
  • image – An image to visually represent the recipe.
  • ingredients – The ingredients needed to prepare the dish.
  • directions – The steps to follow to prepare the dish.
  • notes – Additional information or tips for the recipe.
  • html – Defines if the output is in HTML format.

Examples and Usage

Basic example – Displaying a recipe with minimum attributes. Here, we are using only the ‘recipe_by’ and ‘course’ attributes.

[saswp_tiny_recipe recipe_by="John Doe" course="Main Course" /]

Advanced examples

Displaying a recipe with more detailed attributes. This includes the recipe author, course type, cuisine, difficulty level, number of servings, preparation time, cooking time, and calories.

[saswp_tiny_recipe recipe_by="John Doe" course="Main Course" cusine="Italian" difficulty="Easy" servings="4" prepration_time="10" cooking_time="30" calories="250" /]

Adding an image, ingredients, directions, and notes to the recipe. The image is referenced by its ID, and the ingredients, directions, and notes are arrays with each element representing a step or ingredient.

[saswp_tiny_recipe recipe_by="John Doe" course="Main Course" cusine="Italian" difficulty="Easy" servings="4" prepration_time="10" cooking_time="30" calories="250" image="1" ingredients="['1 cup flour', '2 eggs', '1/2 cup sugar']" directions="['Mix ingredients', 'Bake for 30 minutes', 'Serve hot']" notes="['Serve with ice cream', 'Can be stored for 2 days']" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp_tiny_recipe] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp_tiny_recipe', 'saswp_tiny_recipe_render' );

Shortcode PHP function:

function saswp_tiny_recipe_render( $atts, $content = null ){

    wp_enqueue_style(
         'saswp-g-recipe-css',
         SASWP_PLUGIN_URL . '/modules/gutenberg/assets/css/recipe.css',
         array()                        
    );

    global $saswp_tiny_recipe;

    $output = '';

    $saswp_tiny_recipe = shortcode_atts(
        [
            'recipe_by'         => '',
            'course'            => '',
            'cusine'            => '',
            'difficulty'        => '',
            'servings'          => '',
            'prepration_time'   => '',
            'cooking_time'      => '',
            'calories'          => '',
            'image'             => 0,            
            'ingredients'       => [],
            'directions'        => [],
            'notes'             => [],
            'html'              => true,
        ], $atts );

    foreach ( $atts as $key => $merged_att ) {
        if ( strpos( $key, 'ingradient_name' ) !== false) {
            if(!empty($merged_att)){
                $saswp_tiny_recipe['ingredients'][] = $merged_att;
            }
        }
    }
    foreach ( $atts as $key => $merged_att ) {
        if ( strpos( $key, 'direction_name' ) !== false) {
            if(!empty($merged_att)){
                $saswp_tiny_recipe['directions'][] = $merged_att;
            }
        }
    }
    foreach ( $atts as $key => $merged_att ) {
        if ( strpos( $key, 'notes_name' ) !== false) {
            if(!empty($merged_att)){
                $saswp_tiny_recipe['notes'][] = $merged_att;
            }
        }
    }
    if($saswp_tiny_recipe['html'] == 'true'){
        $image_thumburl = '';
        if ( ! empty( $saswp_tiny_recipe['image'] ) ) {
            $image_id       = intval( $saswp_tiny_recipe['image'] );                
            $image_thumburl = wp_get_attachment_image_url( $image_id);
        }
        $output .= '<div class="saswp-recipe-block-container">';
        $output .= '<div class="saswp-recipe-field-banner"><div class="saswp-book-banner-div">';
        if(!empty($image_thumburl)){    
            $output .= '<img decoding="async" src="'.esc_url($image_thumburl).'">';
        }else{
            $output .= '<img decoding="async" src="" alt="No Image">';
        }
        $output .= '</div></div>'; // saswp-recipe-field-banner div end
        $output .= '<div class="saswp-recipe-block-heading">';
        $output .= '<h4></h5>';
        $output .= '<p class="saswp-recipe-block-author"><strong>'.esc_html__('Recipe By ', 'saswp-for-wp').esc_html($saswp_tiny_recipe['recipe_by']).'</strong></p>';
        $output .= '<div class="saswp-r-course-section">';
        $output .= '<span class="saswp-recipe-block-course" style="width: 30%;"> '.esc_html__('Course: ', 'saswp-for-wp'). '<strong>'.esc_html($saswp_tiny_recipe['course']).'</strong></span>';
        $output .= '<span class="saswp-recipe-block-cuisine" style="width: 30%;"> '.esc_html__('Cusine: ', 'saswp-for-wp'). ' <strong>'.esc_html($saswp_tiny_recipe['cusine']).'</strong></span>';
        $output .= '<span class="saswp-recipe-block-difficulty" style="width: 30%;"> '.esc_html__('Difficulty: ', 'saswp-for-wp'). ': <strong>'.esc_html($saswp_tiny_recipe['difficulty']).'</strong></span>';
        $output .= '</div>'; // saswp-r-course-section div end
        $output .= '</div>'; // saswp-recipe-block-heading div end
        $output .= '<div class="saswp-recipe-block-details"><div class="saswp-recipe-block-details-items">';
        $output .= '<div class="saswp-recipe-block-details-item">';
        $output .= '<p class="saswp-r-b-label">'.esc_html__('Servings', 'saswp-for-wp').'</p>';
        $output .= '<p class="saswp-r-b-unit">'.esc_html($saswp_tiny_recipe['servings']). esc_html__(' minutes', 'saswp-for-wp').' </p>';
        $output .= '</div>';
        $output .= '<div class="saswp-recipe-block-details-item">';
        $output .= '<p class="saswp-r-b-label">'.esc_html__('Preparing Time', 'saswp-for-wp').'</p>';
        $output .= '<p class="saswp-r-b-unit">'.esc_html($saswp_tiny_recipe['prepration_time']). esc_html__(' minutes', 'saswp-for-wp').' </p>';
        $output .= '</div>';
        $output .= '<div class="saswp-recipe-block-details-item">';
        $output .= '<p class="saswp-r-b-label">'.esc_html__('Cooking Time', 'saswp-for-wp').'</p>';
        $output .= '<p class="saswp-r-b-unit">'.esc_html($saswp_tiny_recipe['cooking_time']). esc_html__(' minutes', 'saswp-for-wp').' </p>';
        $output .= '</div>';
        $output .= '<div class="saswp-recipe-block-details-item">';
        $output .= '<p class="saswp-r-b-label">'.esc_html__('Calories', 'saswp-for-wp').'</p>';
        $output .= '<p class="saswp-r-b-unit">'.esc_html($saswp_tiny_recipe['calories']). esc_html__(' kcal', 'saswp-for-wp').' </p>';
        $output .= '</div>';
        $output .= '</div></div>'; // saswp-recipe-block-details div end
        $output .= '<div class="saswp-recipe-block-ingredients">';
        $output .= '<h4>'.esc_html__('INGREDIENTS', 'saswp-for-wp').'</h4>';
        if(isset($saswp_tiny_recipe['ingredients']) && isset($saswp_tiny_recipe['ingredients'][0])){
            $output .= '<ol class="saswp-dirction-ul">';
            foreach ($saswp_tiny_recipe['ingredients'] as $stci_key => $stci_value) {
                $output .= '<li class="saswp-r-b-direction-item"><p>'.esc_html($stci_value).'</p></li>';       
            }
            $output .= '</ol>';
        }
        $output .= '</div>'; // saswp-recipe-block-ingredients div end
        $output .= '<div class="saswp-recipe-block-direction">';
        $output .= '<h4>'.esc_html__('DIRECTION', 'saswp-for-wp').'</h4><ol class="saswp-dirction-ul">';
        if(isset($saswp_tiny_recipe['directions']) && isset($saswp_tiny_recipe['directions'][0])){
            foreach ($saswp_tiny_recipe['directions'] as $stcd_key => $stcd_value) {
                $output .= '<li class="saswp-r-b-direction-item"><p>'.esc_html($stcd_value).'</p></li>';       
            }
        }
        $output .= '</ol></div>'; // saswp-recipe-block-direction div end
        $output .= '<div class="saswp-recipe-block-direction">';
        $output .= '<h4>'.esc_html__('NOTES', 'saswp-for-wp').'</h4><ol class="saswp-dirction-ul">';
        if(isset($saswp_tiny_recipe['notes']) && isset($saswp_tiny_recipe['notes'][0])){
            foreach ($saswp_tiny_recipe['notes'] as $stcn_key => $stcn_value) {
                $output .= '<li class="saswp-r-b-direction-item"><p>'.esc_html($stcn_value).'</p></li>';       
            }
        }
        $output .= '</ol></div>'; // saswp-recipe-block-direction div end
        $output .= '</div>'; // saswp-recipe-block-container div end
    }
    return $output;
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/modules/tinymce/register-shortcodes.php

[saswp-breadcrumbs] Shortcode

The “saswp-breadcrumbs” shortcode from the Schema and Structured Data for WP & AMP plugin is designed to generate a breadcrumbs trail for your website. This shortcode helps in enhancing the site’s navigation and SEO by creating a hierarchical representation of the site’s structure. The “hide_post_title” attribute allows you to exclude the current post title from the breadcrumbs. The shortcode also provides styling options for the breadcrumbs.

Shortcode: [saswp-breadcrumbs]

Parameters

Here is a list of all possible saswp-breadcrumbs shortcode parameters and attributes:

  • hide_post_title – hides the current post title in the breadcrumb if set to 1

Examples and Usage

Basic example – The basic usage of the ‘saswp-breadcrumbs’ shortcode. This shortcode will render breadcrumbs based on the titles provided in the ‘sd_data’ global variable.

[saswp-breadcrumbs /]

Advanced examples

Using the shortcode to render breadcrumbs but hide the current post title. The ‘hide_post_title’ attribute is used to control whether the current post title is included in the breadcrumbs or not. If set to ‘1’, the current post title will be hidden.

[saswp-breadcrumbs hide_post_title=1 /]

Using the shortcode to render breadcrumbs and show the current post title. The ‘hide_post_title’ attribute is set to ‘0’, which means the current post title will be included in the breadcrumbs.

[saswp-breadcrumbs hide_post_title=0 /]

Note that if the ‘hide_post_title’ attribute is not included in the shortcode, the default value is ‘0’, which means the current post title will be shown.

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-breadcrumbs] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('saswp-breadcrumbs', 'saswp_render_breadcrumbs_html');

Shortcode PHP function:

function saswp_render_breadcrumbs_html($atts){

    global $sd_data,$post;
    $attr = shortcode_atts(
        array(
            'hide_post_title' => '',
        ), $atts, 'saswp-breadcrumbs' );

    $hide_post_title = ($attr['hide_post_title']) ? $attr['hide_post_title'] : 0;
    $get_current_post_title = get_post_field('post_title',$post->ID);
    $breadcrumbs = '';    
    if(!empty($sd_data['titles'])){

        $breadcrumbs .= '<style>';

        $breadcrumbs .= '.saswp-breadcrumbs-li{            
            display: inline-block;
            list-style-type: none;
            font-size: 12px;
            text-transform: uppercase;
            margin-right: 5px;
        }
        .saswp-breadcrumbs-li a:after{
            content: "\25BA";
            font-family: "icomoon";
            font-size: 12px;
            display: inline-block;
            color: #bdbdbd;
            padding-left: 5px;
            position: relative;
            top: 1px;
        }
        ';
        $breadcrumbs .= '</style>';
        $breadcrumbs .= '<ul class="saswp-breadcrumbs-ul">';

            foreach ($sd_data['titles'] as $key => $value) {
                if($hide_post_title == 1 && $value == $get_current_post_title){
                    // do nothing
                }else{
                    $breadcrumbs .= '<li class="saswp-breadcrumbs-li" ><a href="'.esc_url($sd_data['links'][$key]).'">'.esc_html($value).'</a></li>';

                }
                
            }

        $breadcrumbs .= '</ul>';

    }

    return $breadcrumbs;
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/output/function.php

[saswp-location] Shortcode

The SASWP Location shortcode is a custom function in the Schema & Structured Data for WP plugin that adds location info to your content. This shortcode takes an ‘id’ attribute to fetch and display the specific location data. It’s an effective tool for enriching your site’s metadata and enhancing SEO.

Shortcode: [saswp-location]

Parameters

Here is a list of all possible saswp-location shortcode parameters and attributes:

  • id – unique identifier of the location data

Examples and Usage

Basic example – The following shortcode is used to display a specific location by referencing its ID.

[saswp-location id=1 /]

Advanced examples

Displaying multiple locations by referencing their IDs. The shortcode will generate and display the locations based on the IDs provided.

[saswp-location id="1,2,3" /]

Displaying a location with additional parameters. In this example, we’re displaying a location with the ID of 1, but also specifying additional parameters for customization.

[saswp-location id=1 param1="value1" param2="value2" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [saswp-location] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'saswp-location', 'saswp_location_shortcode_render');

Shortcode PHP function:

function saswp_location_shortcode_render($attr){

    if(isset($attr['id'])){
        echo saswp_add_location_content($attr['id']);
    }
    
}

Code file location:

schema-and-structured-data-for-wp/schema-and-structured-data-for-wp/output/location.php

Conclusion

Now that you’ve learned how to embed the Schema & Structured Data for WP & AMP 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *