Structured Content (JSON-LD) Shortcodes

Below, you’ll find a detailed guide on how to add the Structured Content (JSON-LD) #wpsc 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 Structured Content (JSON-LD) #wpsc Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Structured Content (JSON-LD) #wpsc Plugin and the shortcodes it provides:

Plugin Icon
Structured Content (JSON-LD) #wpsc

"Structured Content (JSON-LD) #wpsc is a powerful WordPress plugin that enhances your website's SEO by generating structured JSON-LD data. Perfect for improving your online visibility."

★★★★✩ (22) Active Installs: 20000+ Tested with: 6.1.4 PHP Version: 7.0
Included Shortcodes:
  • [sc_fs_faq]
  • [sc_fs_multi_faq]
  • [sc_fs_job]
  • [sc_fs_event]
  • [sc_fs_person]
  • [sc_fs_course]
  • [sc_fs_local_business]

Structured Content (JSON-LD) [sc_fs_faq] Shortcode

The Structured Content plugin shortcode ‘sc_fs_faq’ is used to create a FAQ section. It accepts various attributes to customize the FAQ’s appearance. This shortcode fetches and displays FAQ data, including images. It also supports custom CSS classes and HTML tags for headlines. It can handle serialized data and animate summaries.

Shortcode: [sc_fs_faq]

Parameters

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

  • version – Specifies the version of your shortcode
  • css_class – Assigns a specific CSS class to the FAQ section
  • question_tag – Defines the HTML tag for the FAQ question
  • elements – Contains the elements of the FAQ section
  • headline – Sets the headline tag for the FAQ section
  • img – Adds an image to the FAQ section
  • img_alt – Provides an alternate text for the FAQ image
  • question – Text of the FAQ question
  • answer – Text of the FAQ answer
  • html – Allows HTML content in the FAQ section
  • description – Description of the FAQ section
  • className – Assigns a specific class to the FAQ block
  • title_tag – Defines the HTML tag for the FAQ title
  • generate_title_id – Generates a unique ID for the FAQ title
  • summary – Adds a summary to the FAQ section
  • animate_summary – Enables animation for the FAQ summary

Examples and Usage

Basic example – Display a FAQ section with a single question and answer.

[sc_fs_faq question="What is WordPress?" answer="WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database." /]

Advanced examples

Display a FAQ section with a custom headline, question, answer, and an image.

[sc_fs_faq headline="WordPress FAQ" question="What is a WordPress theme?" answer="A WordPress theme provides all of the front end styling of your WordPress site." img="123" /]

Display a FAQ section with multiple elements.

[sc_fs_faq elements='[{"question":"What is a WordPress plugin?","answer":"A WordPress plugin is a piece of software that can be added to a WordPress website to extend functionality or add new features."},{"question":"What is a WordPress post?","answer":"A WordPress post is what makes up the blog aspect of your site."}]' /]

Display a FAQ section with a custom CSS class.

[sc_fs_faq css_class="my-custom-class" question="What is a WordPress page?" answer="A WordPress page is a static content that is not part of your blog's chronological flow." /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_faq', array( $this, 'faq' ) );

Shortcode PHP function:

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

		if ( ! array_key_exists( 'version', $atts ) ) {

			$merged_atts = shortcode_atts(
				array(
					'css_class'    => '',
					'question_tag' => 'h2',
					'elements'     => '',
				),
				$atts
			);

			if ( $merged_atts['elements'] === '' ) {

				$merged_atts = shortcode_atts(
					array(
						'css_class' => '',
						'headline'  => 'h2',
						'img'       => 0,
						'img_alt'   => '',
						'question'  => '',
						'answer'    => '',
						'html'      => 'true',
						'elements'  => '',
					),
					$atts
				);

				if ( ! empty( $merged_atts['img'] ) ) {
					$image_id       = intval( $merged_atts['img'] );
					$image_url      = wp_get_attachment_url( $image_id );
					$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
					$image_meta     = wp_get_attachment_metadata( $image_id );
					if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
						$merged_atts['img_url']       = $image_url;
						$merged_atts['thumbnail_url'] = $image_thumburl;
						$merged_atts['img_size']      = array( $image_meta['width'], $image_meta['height'] );
						if ( empty( $merged_atts['img_alt'] ) ) {
							$merged_atts['img_alt'] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
						}
					} else {
						$merged_atts['img'] = 0;
					}
				}
				$merged_atts['headline_open_tag']  = '<' . $merged_atts['headline'] . '>';
				$merged_atts['headline_close_tag'] = '</' . $merged_atts['headline'] . '>';

				$atts = $merged_atts;

				if ( isset( $atts['description'] ) && $atts['description'] !== '' ) {
					$content = $atts['description'];
				}

				ob_start();
				include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/faq-deprecated.php';
				$output = ob_get_contents();
				ob_end_clean();

				return $output;

			} else {

				if ( ! is_array( $merged_atts['elements'] ) ) {
					$a                       = str_replace( "'", '"', $merged_atts['elements'] );
					$a                       = unserialize( $a );
					$merged_atts['elements'] = $a;
				}

				foreach ( $merged_atts['elements'] as $key => $element ) {
					if ( ! empty( $element['imageID'] ) ) {
						$image_id       = intval( $element['imageID'] );
						$image_url      = wp_get_attachment_url( $image_id );
						$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
						$image_meta     = wp_get_attachment_metadata( $image_id );
						if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
							$merged_atts['elements'][ $key ]['img_url']       = $image_url;
							$merged_atts['elements'][ $key ]['thumbnail_url'] = $image_thumburl;
							$merged_atts['elements'][ $key ]['img_size']      = array(
								$image_meta['width'],
								$image_meta['height'],
							);
							if ( empty( $merged_atts['elements'][ $key ]['img_alt'] ) ) {
								$merged_atts['elements'][ $key ]['img_alt'] = get_post_meta(
									$image_id,
									'_wp_attachment_image_alt',
									true
								);
							}
						} else {
							$merged_atts['elements'][ $key ]['img'] = 0;
						}
					}
				}

				$atts = $merged_atts;

				ob_start();
				include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/faq.php';
				$output = ob_get_contents();
				ob_end_clean();

				return $output;
			}
		} else {

			$temp_content = preg_split( "/(\r\n|\r|\n)/", $content, - 1, PREG_SPLIT_NO_EMPTY );
			$elements     = array();

			foreach ( $temp_content as $key => $value ) {
				$elements[] = json_decode( $value );
			}

			$atts = shortcode_atts(
				array(
					'className'         => '',
					'css_class'         => '',
					'title_tag'         => 'h2',
					'generate_title_id' => false,
					'summary'           => false,
					'animate_summary'   => false,
					'elements'          => $elements,
				),
				$atts
			);

			ob_start();
			include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/blocks/faq.php';
			$output = ob_get_contents();
			ob_end_clean();

			return $output;
		}

	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) [sc_fs_multi_faq] Shortcode

The ‘sc_fs_multi_faq’ shortcode from the Structured Content Plugin creates a multi-faceted FAQ section. It pulls data from specified elements like headlines, questions, answers, and images. . The shortcode allows customization through attributes like ‘css_class’, ‘count’, and ‘html’. Additionally, it manages image elements by fetching the image URL, thumbnail, and metadata. Shortcode function ‘multi_faq’ returns the output after including the ‘multi-faq.php’ template, providing a structured FAQ section.

Shortcode: [sc_fs_multi_faq]

Parameters

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

  • css_class – Name of the CSS class to style the FAQ section
  • count – Number of FAQs to display
  • html – Allows HTML content in the FAQ section
  • elements – Array of FAQs with corresponding details
  • headline – The main title of each FAQ
  • question – The question part of each FAQ
  • answer – The answer part of each FAQ
  • image – The image ID to display with each FAQ

Examples and Usage

Basic example – A simple FAQ section with a single question and answer.

[sc_fs_multi_faq css_class="faq-section" count="1" headline-1="Question 1" question-1="What is shortcode?" answer-1="Shortcode is a specific code that lets you do nifty things with very little effort." /]

Advanced examples – A FAQ section with multiple questions and answers, including images.

Using the shortcode to display a FAQ section with two questions and answers, and an image for the second question. The image will be loaded by its ID.

[sc_fs_multi_faq css_class="faq-section" count="2" headline-1="Question 1" question-1="What is shortcode?" answer-1="Shortcode is a specific code that lets you do nifty things with very little effort." headline-2="Question 2" question-2="How to use shortcode?" answer-2="To use shortcode, you just need to place it in the content editor of your page or post." image-2="123" /]

Using the shortcode to display a FAQ section with three questions and answers, including images for the second and third questions. The images will be loaded by their IDs. Also, this example uses a different CSS class.

[sc_fs_multi_faq css_class="advanced-faq-section" count="3" headline-1="Question 1" question-1="What is shortcode?" answer-1="Shortcode is a specific code that lets you do nifty things with very little effort." headline-2="Question 2" question-2="How to use shortcode?" answer-2="To use shortcode, you just need to place it in the content editor of your page or post." image-2="123" headline-3="Question 3" question-3="How to customize shortcode?" answer-3="You can customize shortcode by adding or modifying its attributes." image-3="456" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_multi_faq', array( $this, 'multi_faq' ) );

Shortcode PHP function:

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

		$merged_atts = shortcode_atts(
			array(
				'css_class' => '',
				'count'     => '1',
				'html'      => true,
				'elements'  => array(),
			),
			$atts
		);

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

		foreach ( $merged_atts['elements'] as $key => $element ) {
			if ( ! empty( $element['image'] ) ) {
				$image_id       = intval( $element['image'] );
				$image_url      = wp_get_attachment_url( $image_id );
				$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
				$image_meta     = wp_get_attachment_metadata( $image_id );
				if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
					$merged_atts['elements'][ $key ]['img_url']       = $image_url;
					$merged_atts['elements'][ $key ]['thumbnail_url'] = $image_thumburl;
					$merged_atts['elements'][ $key ]['img_size']      = array(
						$image_meta['width'],
						$image_meta['height'],
					);
					if ( empty( $merged_atts['elements'][ $key ]['img_alt'] ) ) {
						$merged_atts['elements'][ $key ]['img_alt'] = get_post_meta(
							$image_id,
							'_wp_attachment_image_alt',
							true
						);
					}
				} else {
					$merged_atts['elements'][ $key ]['image'] = 0;
				}
			}
		}

		$atts = $merged_atts;

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/multi-faq.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;

	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) [sc_fs_job] Shortcode

The ‘sc_fs_job’ shortcode from the Structured Content Plugin is designed to create a job listing. It allows you to customize various job elements such as title, description, employment type, company name, and location. It fetches the logo from the provided ‘logo_id’ and sets its URL, thumbnail, size, and alternative text. If a ‘description’ is provided, it replaces the default content. The output is then returned after being processed through the ‘job.php’ template.

Shortcode: [sc_fs_job]

Parameters

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

  • className – The custom class name for the job post.
  • css_class – The CSS class for styling the job section.
  • title_tag – The HTML tag used for the job title.
  • generate_title_id – If true, generates a unique id for the job title.
  • custom_title_id – The unique id for the job title, if specified.
  • html – If true, the content supports HTML markup.
  • title – The title of the job post.
  • description – Description providing details about the job.
  • valid_through – The expiry date of the job post.
  • employment_type – The type of employment (full-time, part-time, etc).
  • company_name – The name of the company offering the job.
  • same_as – URL representing the same content.
  • logo_id – The WordPress media id of the company logo.
  • street_address – The street address of the job location.
  • address_locality – The city or town of the job location.
  • address_region – The state or province of the job location.
  • postal_code – The postal code of the job location.
  • address_country – The country of the job location.
  • currency_code – The currency for the job salary.
  • quantitative_value – The numeric value of the base salary.
  • base_salary – The base salary for the job.
  • job_location_type – The type of job location (e.g., “TELECOMMUTE” for remote jobs).

Examples and Usage

Basic example – Displaying a job post with a title and description.

[sc_fs_job title="Software Developer" description="We are looking for a skilled Software Developer to join our team." /]

Advanced examples

Displaying a job post with additional details such as employment type, company name, and location.

[sc_fs_job title="Software Developer" description="We are looking for a skilled Software Developer to join our team." employment_type="Full Time" company_name="Tech Corp" address_locality="New York" address_region="NY" /]

Displaying a job post with salary details and a company logo. The ‘logo_id’ parameter refers to the ID of the image uploaded to the WordPress media library.

[sc_fs_job title="Software Developer" description="We are looking for a skilled Software Developer to join our team." base_salary="60000" currency_code="USD" logo_id="123" /]

Displaying a job post with a custom CSS class. This allows for further customization of the job post appearance via CSS.

[sc_fs_job title="Software Developer" description="We are looking for a skilled Software Developer to join our team." css_class="my-custom-class" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_job', array( $this, 'job' ) );

Shortcode PHP function:

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

		$merged_atts = shortcode_atts(
			array(
				'className'          => '',
				'css_class'          => '',
				'title_tag'          => 'h2',
				'generate_title_id'  => false,
				'custom_title_id'    => '',
				'html'               => true,
				'title'              => '',
				'description'        => '',
				'valid_through'      => '',
				'employment_type'    => '',
				'company_name'       => '',
				'same_as'            => '',
				'logo_id'            => '',
				'street_address'     => '',
				'address_locality'   => '',
				'address_region'     => '',
				'postal_code'        => '',
				'address_country'    => '',
				'currency_code'      => '',
				'quantitative_value' => '',
				'base_salary'        => '',
				'job_location_type'  => false,
			),
			$atts
		);

		if ( ! empty( $merged_atts['logo_id'] ) ) {
			$image_id       = intval( $merged_atts['logo_id'] );
			$image_url      = wp_get_attachment_url( $image_id );
			$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
			$image_meta     = wp_get_attachment_metadata( $image_id );
			if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
				$merged_atts['logo_url']      = $image_url;
				$merged_atts['thumbnail_url'] = $image_thumburl;
				$merged_atts['logo_size']     = array( $image_meta['width'], $image_meta['height'] );
				if ( empty( $merged_atts['logo_alt'] ) ) {
					$merged_atts['logo_alt'] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
				}
			} else {
				$merged_atts['logo'] = 0;
			}
		}

		$atts = $merged_atts;

		if ( isset( $atts['description'] ) && $atts['description'] !== '' ) {
			$content = $atts['description'];
		}

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/job.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;
	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) #wpsc [sc_fs_event] Shortcode

The ‘sc_fs_event’ shortcode from the Structured Content Plugin is designed to generate event details on your WordPress site. This shortcode allows you to customize event details such as title, description, location, start and end date, and more. It also provides options for image handling, including fetching image URLs and metadata. The code merges the attributes provided and outputs the structured content in the ‘event.php’ template.

Shortcode: [sc_fs_event]

Parameters

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

  • className – the CSS class name for the event.
  • css_class – additional CSS classes for the event.
  • title_tag – HTML tag for the event title.
  • generate_title_id – generates an ID for the event title.
  • elements – array of attributes for the event.
  • html – determines if the event is visible.
  • title – the title of the event.
  • custom_title_id – custom ID for the event title.
  • description – the description of the event.
  • event_location – the location of the event.
  • status – the status of the event.
  • online_url – the online URL of the event.
  • prev_start_date – the previous start date of the event.
  • event_attendance_mode – the attendance mode of the event.
  • start_date – the start date of the event.
  • end_date – the end date of the event.
  • street_address – the street address of the event location.
  • address_locality – the locality of the event location.
  • address_region – the region of the event location.
  • postal_code – the postal code of the event location.
  • address_country – the country of the event location.
  • currency_code – the currency code for the event price.
  • price – the price of the event.
  • image_id – the ID of the event image.
  • performer – the performer at the event.
  • performer_name – the name of the performer.
  • offer_availability – the availability of the event.
  • offer_url – the URL of the event offer.
  • offer_valid_from – the date when the offer becomes valid.

Examples and Usage

Basic example – Display a structured event with a title and description.

[sc_fs_event title="My Event" description="This is a description of my event." /]

Advanced examples

Display a structured event with additional information such as location, start date, end date, and an image.

[sc_fs_event title="My Event" description="This is a description of my event." event_location="New York" start_date="2022-01-01" end_date="2022-01-02" image_id="123" /]

Show a structured event with an online URL, status, and attendance mode.

[sc_fs_event title="My Event" description="This is a description of my event." online_url="http://www.myevent.com" status="EventScheduled" event_attendance_mode="MixedEventAttendanceMode" /]

Display a structured event with additional information about the performer, offer availability, offer URL, and valid offer date.

[sc_fs_event title="My Event" description="This is a description of my event." performer="John Doe" performer_name="John" offer_availability="InStock" offer_url="http://www.myevent.com/tickets" offer_valid_from="2022-01-01" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_event', array( $this, 'event' ) );

Shortcode PHP function:

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

		$merged_atts = shortcode_atts(
			array(
				'className'         => '',
				'css_class'         => '',
				'title_tag'         => 'h2',
				'generate_title_id' => false,
				'elements'          => '',
			),
			$atts
		);

		if ( $merged_atts['elements'] === '' ) {
			$single_atts            = shortcode_atts(
				array(
					'className'             => '',
					'css_class'             => '',
					'html'                  => 'true',
					'title'                 => '',
					'custom_title_id'       => '',
					'description'           => $content,
					'event_location'        => '',
					'status'                => 'EventScheduled',
					'online_url'            => '',
					'prev_start_date'       => '',
					'event_attendance_mode' => '',
					'start_date'            => '',
					'end_date'              => '',
					'street_address'        => '',
					'address_locality'      => '',
					'address_region'        => '',
					'postal_code'           => '',
					'address_country'       => '',
					'currency_code'         => '',
					'price'                 => '',
					'image_id'              => '',
					'performer'             => '',
					'performer_name'        => '',
					'offer_availability'    => '',
					'offer_url'             => '',
					'offer_valid_from'      => '',
				),
				$atts
			);
			$single_atts['visible'] = $single_atts['html'] === 'true' ? true : false;
			unset( $single_atts['html'] );
			$merged_atts['elements'] = array( $single_atts );
		}

		if ( ! empty( $merged_atts['image_id'] ) ) {
			$image_id       = intval( $merged_atts['image_id'] );
			$image_url      = wp_get_attachment_url( $image_id );
			$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
			$image_meta     = wp_get_attachment_metadata( $image_id );
			if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
				$merged_atts['img_url']       = $image_url;
				$merged_atts['thumbnail_url'] = $image_thumburl;
				$merged_atts['img_size']      = array( $image_meta['width'], $image_meta['height'] );
				if ( empty( $merged_atts['img_alt'] ) ) {
					$merged_atts['img_alt'] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
				}
			} else {
				$merged_atts['img'] = 0;
			}
		}

		foreach ( $merged_atts['elements'] as $key => $element ) {

			$merged_atts['elements'][ $key ]['status']                = isset( $element['status'] ) && $element['status'] !== '' ? $element['status'] : __( 'EventScheduled' );
			$merged_atts['elements'][ $key ]['event_attendance_mode'] = isset( $element['event_attendance_mode'] ) && $element['event_attendance_mode'] != '' ? $element['event_attendance_mode'] : __( 'MixedEventAttendanceMode' );

			if ( ! empty( $element['image_id'] ) ) {
				$image_id       = intval( $element['image_id'] );
				$image_url      = wp_get_attachment_url( $image_id );
				$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
				$image_meta     = wp_get_attachment_metadata( $image_id );
				if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
					$merged_atts['elements'][ $key ]['img_url']       = $image_url;
					$merged_atts['elements'][ $key ]['thumbnail_url'] = $image_thumburl;
					$merged_atts['elements'][ $key ]['img_size']      = array(
						$image_meta['width'],
						$image_meta['height'],
					);
					if ( empty( $merged_atts['elements'][ $key ]['img_alt'] ) ) {
						$merged_atts['elements'][ $key ]['img_alt'] = get_post_meta(
							$image_id,
							'_wp_attachment_image_alt',
							true
						);
					}
				} else {
					$merged_atts['elements'][ $key ]['img'] = 0;
				}
			}
		}

		$atts = $merged_atts;

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/event.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;
	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) [sc_fs_person] Shortcode

The ‘sc_fs_person’ shortcode is a powerful tool that generates structured content for a person’s profile. It allows you to customize various attributes like name, job title, image, contact details, address, and more. This shortcode also facilitates linking to colleagues’ profiles and other related URLs. It fetches the image linked to the profile and provides options to display the full image or a thumbnail. The shortcode ensures the profile’s structured presentation, enhancing the overall user experience.

Shortcode: [sc_fs_person]

Parameters

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

  • className – The CSS class added to the person element.
  • css_class – An additional CSS class for styling.
  • html – If set to true, HTML tags in content are allowed.
  • person_name – The displayed name of the person.
  • generate_title_id – If true, an ID is generated for the title.
  • custom_title_id – Custom ID for the title, if provided.
  • alternate_name – The alternative name of the person.
  • job_title – The job title of the person.
  • image_id – The ID of the person’s image.
  • birthdate – The birthdate of the person.
  • email – The email address of the person.
  • telephone – The phone number of the person.
  • url – The URL of the person’s website.
  • colleague – The colleague’s URL, separated by commas.
  • street_address – The street address of the person.
  • address_locality – The city or locality of the person.
  • address_region – The state or region of the person.
  • postal_code – The postal code of the person.
  • address_country – The country of the person.
  • same_as – Other URLs representing the person, separated by commas.
  • works_for_name – The name of the person’s employer.
  • works_for_alt – The alternate name of the person’s employer.
  • works_for_url – The URL of the person’s employer.
  • works_for_logo – The logo of the person’s employer.

Examples and Usage

Basic example – Displays a person’s basic information using the shortcode.

[sc_fs_person person_name="John Doe" job_title="Software Engineer" /]

Advanced examples

Displaying a person’s information with additional details like email, telephone number, and address.

[sc_fs_person person_name="John Doe" job_title="Software Engineer" email="john.doe@example.com" telephone="1234567890" street_address="123 Main St" address_locality="City" address_region="State" postal_code="12345" address_country="Country" /]

Using the shortcode to display a person’s information along with their image. The image is fetched using the image_id attribute. The shortcode also includes the person’s colleagues’ links and social media profiles under the same_as attribute.

[sc_fs_person person_name="John Doe" job_title="Software Engineer" image_id="1" colleague="www.colleague1.com,www.colleague2.com" same_as="www.facebook.com/johndoe,www.linkedin.com/in/johndoe" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_person', array( $this, 'person' ) );

Shortcode PHP function:

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

		$merged_atts = shortcode_atts(
			array(
				'className'         => '',
				'css_class'         => '',
				'html'              => true,
				'person_name'       => '',
				'generate_title_id' => false,
				'custom_title_id'   => '',
				'alternate_name'    => '',
				'job_title'         => '',
				'image_id'          => '',
				'birthdate'         => '',
				'email'             => '',
				'telephone'         => '',
				'url'               => '',
				'colleague'         => '',
				'street_address'    => '',
				'address_locality'  => '',
				'address_region'    => '',
				'postal_code'       => '',
				'address_country'   => '',
				'same_as'           => '',
				'works_for_name'    => '',
				'works_for_alt'     => '',
				'works_for_url'     => '',
				'works_for_logo'    => '',
			),
			$atts
		);

		if ( ! empty( $merged_atts['image_id'] ) ) {
			$image_id       = intval( $merged_atts['image_id'] );
			$image_url      = wp_get_attachment_url( $image_id );
			$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
			$image_meta     = wp_get_attachment_metadata( $image_id );

			if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
				$merged_atts['image_url']     = $image_url;
				$merged_atts['thumbnail_url'] = $image_thumburl;
				$merged_atts['image_size']    = array( $image_meta['width'], $image_meta['height'] );
				if ( empty( $merged_atts['image_alt'] ) ) {
					$merged_atts['image_alt'] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
				}
			} else {
				$merged_atts['image'] = 0;
			}
		}

		if ( isset( $atts['description'] ) && $atts['description'] !== '' ) {
			$content = $atts['description'];
		}
		if ( isset( $atts['homepage'] ) && $atts['homepage'] !== '' ) {
			$merged_atts['url'] = $atts['homepage'];
		}

		if ( isset( $atts['colleague'] ) ) {
			$merged_atts['links'] = explode( ',', $atts['colleague'] );
		}

		if ( isset( $atts['colleagues'] ) ) {
			foreach ( $atts['colleagues'] as $colleague ) {
				$merged_atts['links'][] = $colleague['url'];
			}
		}

		if ( isset( $atts['same_as'] ) ) {
			if ( is_array( $atts['same_as'] ) ) {
				$same_as = array();
				foreach ( $merged_atts['same_as'] as $same ) {
					$same_as[] = $same['url'];
				}
				$merged_atts['same_as'] = $same_as;
			} else {
				$merged_atts['same_as'] = explode( ',', $atts['same_as'] );
			}
		} else {
			$merged_atts['same_as'] = array();
		}

		$atts = $merged_atts;

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/person.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;
	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) [sc_fs_course] Shortcode

The ‘sc_fs_course’ shortcode is a structured-content plugin that allows you to customize your course content. It provides options to modify class names, CSS classes, title tags, and elements. This shortcode also enables the generation of title IDs and the input of custom descriptions. It handles the visibility of the content and allows for the inclusion of provider details. Shortcode: [sc_fs_course]

Shortcode: [sc_fs_course]

Parameters

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

  • className – a name to apply a specific style to the course.
  • css_class – additional CSS class for custom styling.
  • title_tag – HTML tag for the course title.
  • generate_title_id – generates a unique ID for the course title.
  • elements – contains all course elements if not empty.
  • html – controls the visibility of the course.
  • title – title of the course.
  • custom_title_id – custom ID for the course title.
  • description – detailed explanation about the course.
  • provider_name – name of the course provider.
  • provider_same_as – relates the course provider to an entity.

Examples and Usage

Basic example – The shortcode ‘sc_fs_course’ is used to display a course with default settings. By default, the title tag is ‘h2’ and no additional CSS class or elements are specified.

[sc_fs_course /]

Advanced examples

In this example, the shortcode ‘sc_fs_course’ is used with added attributes. The title tag is set to ‘h3’, a CSS class ‘my-course’ is added, and the ‘generate_title_id’ is set to true.

[sc_fs_course title_tag="h3" css_class="my-course" generate_title_id="true" /]

In this more advanced example, the shortcode ‘sc_fs_course’ is used with ‘elements’ attribute. The ‘elements’ attribute takes an array of parameters. Here, we are setting the title, description, provider name and provider same as parameters for the course.

[sc_fs_course elements="title='Course Title', description='Course Description', provider_name='Provider Name', provider_same_as='Provider URL'" /]

Note: The ‘elements’ attribute takes an array of parameters. The parameters should be formatted as ‘key=value’ and separated by commas.

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_course', array( $this, 'course' ) );

Shortcode PHP function:

function course( $atts, $content = null ) {
		$merged_atts = shortcode_atts(
			array(
				'className'         => '',
				'css_class'         => '',
				'title_tag'         => 'h2',
				'generate_title_id' => false,
				'elements'          => '',
			),
			$atts
		);

		if ( $merged_atts['elements'] === '' ) {
			$single_atts = shortcode_atts(
				array(
					'className'        => '',
					'css_class'        => '',
					'html'             => 'true',
					'title'            => '',
					'custom_title_id'  => '',
					'description'      => $content,
					'provider_name'    => '',
					'provider_same_as' => '',
				),
				$atts
			);

			$single_atts['visible'] = $single_atts['html'] === 'true' ? true : false;
			unset( $single_atts['html'] );
			$merged_atts['elements'] = array( $single_atts );
		}

		$atts = $merged_atts;

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/course.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;

	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Structured Content (JSON-LD) [sc_fs_local_business] Shortcode

The ‘sc_fs_local_business’ shortcode from the Structured Content Plugin is designed to display local business details. It merges multiple attributes like business name, contact details, opening hours, and location coordinates, among others. The shortcode fetches image and logo details if provided, and includes them in the output. The final content is generated from a template file named ‘local-business.php’, providing a structured display of a local business on your WordPress site.

Shortcode: [sc_fs_local_business]

Parameters

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

  • className – CSS class name for the local business block
  • custom_title_id – Custom ID for the title of the business
  • generate_title_id – Generates a unique ID for the title
  • html – If set to true, the output will be in HTML
  • title_tag – HTML tag for the title (default is ‘h2’)
  • address_country – Country where the business is located
  • address_locality – City or locality of the business
  • address_region – Region or state of the business
  • align – Alignment of the local business block
  • business_name – Name of the local business
  • contact_email – Business contact email address
  • contact_telephone – Contact phone number of the business
  • contact_type – Type of contact (e.g., customer service)
  • contact_url – URL for the contact page
  • currencies_accepted – Currencies accepted by the business
  • description – Description of the business
  • email – Email address of the business
  • founding_date – Date when the business was founded
  • has_map – If set to true, a map will be displayed
  • image_thumbnail – Thumbnail image of the business
  • image_id – ID of the business image
  • logo_thumbnail – Thumbnail of the business logo
  • logo_id – ID of the business logo
  • latitude – Latitude for the business location
  • longitude – Longitude for the business location
  • opening_hours – Opening hours of the business
  • postal_code – Postal code of the business address
  • price_range – Price range of the business services/products
  • same_as – URLs of the business’s social media profiles
  • street_address – Street address of the business
  • telephone – Telephone number of the business
  • textAlign – Text alignment within the local business block
  • website – Website URL of the business

Examples and Usage

Basic example – Displays local business information using a shortcode with the business name and contact email parameters.

[sc_fs_local_business business_name="Your Business Name" contact_email="contact@yourbusiness.com" /]

Advanced examples

Using the shortcode to display detailed local business information by including parameters such as business name, contact email, contact telephone, and website. This shortcode will display the name of the business, the contact email and telephone number, and the website URL.

[sc_fs_local_business business_name="Your Business Name" contact_email="contact@yourbusiness.com" contact_telephone="123-456-7890" website="www.yourbusiness.com" /]

Using the shortcode to display local business information with an image and logo. This shortcode will display the business name, contact email, and also include an image and logo for the business. The image and logo are referenced by their ID numbers in the media library.

[sc_fs_local_business business_name="Your Business Name" contact_email="contact@yourbusiness.com" image_id="1" logo_id="2" /]

Using the shortcode to display local business information including the street address, postal code, and opening hours. This shortcode will display the business name, contact email, and detailed location and operating information.

[sc_fs_local_business business_name="Your Business Name" contact_email="contact@yourbusiness.com" street_address="123 Main St" postal_code="12345" opening_hours="Mon-Fri 9am-5pm" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sc_fs_local_business', array( $this, 'local_business' ) );

Shortcode PHP function:

function local_business( $atts, $content = null ) {
		$merged_atts = shortcode_atts(
			array(
				'className'           => '',
				'custom_title_id'     => '',
				'generate_title_id'   => false,
				'html'                => true,
				'title_tag'           => 'h2',
				'address_country'     => '',
				'address_locality'    => '',
				'address_region'      => '',
				'align'               => '',
				'business_name'       => '',
				'contact_email'       => '',
				'contact_telephone'   => '',
				'contact_type'        => '',
				'contact_url'         => '',
				'currencies_accepted' => '',
				'description'         => '',
				'email'               => '',
				'founding_date'       => '',
				'has_map'             => '',
				'image_thumbnail'     => '',
				'image_id'            => '',
				'logo_thumbnail'      => '',
				'logo_id'             => '',
				'latitude'            => '',
				'longitude'           => '',
				'opening_hours'       => array(),
				'postal_code'         => '',
				'price_range'         => '',
				'same_as'             => array(),
				'street_address'      => '',
				'telephone'           => '',
				'textAlign'           => '',
				'website'             => '',
			),
			$atts
		);

		if ( $merged_atts['image_id'] !== '' ) {
			$image_id       = intval( $merged_atts['image_id'] );
			$image_url      = wp_get_attachment_url( $image_id );
			$image_thumburl = wp_get_attachment_image_url( $image_id, array( 150, 150 ) );
			$image_meta     = wp_get_attachment_metadata( $image_id );

			if ( $image_thumburl !== false && $image_meta !== false && $image_url !== false ) {
				$merged_atts['image_url']       = $image_url;
				$merged_atts['image_thumbnail'] = $image_thumburl;
				$merged_atts['image_size']      = array( $image_meta['width'], $image_meta['height'] );
				if ( empty( $merged_atts['image_alt'] ) ) {
					$merged_atts['image_alt'] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
				}
			} else {
				$merged_atts['image'] = 0;
			}
		}

		if ( $merged_atts['logo_id'] !== '' ) {
			$logo_id       = intval( $merged_atts['logo_id'] );
			$logo_url      = wp_get_attachment_url( $logo_id );
			$logo_thumburl = wp_get_attachment_image_url( $logo_id, array( 150, 150 ) );
			$logo_meta     = wp_get_attachment_metadata( $logo_id );

			if ( $logo_thumburl !== false && $logo_meta !== false && $logo_url !== false ) {
				$merged_atts['logo_url']       = $logo_url;
				$merged_atts['logo_thumbnail'] = $logo_thumburl;
				$merged_atts['logo_size']      = array( $logo_meta['width'], $logo_meta['height'] );
				if ( empty( $merged_atts['logo_alt'] ) ) {
					$merged_atts['logo_alt'] = get_post_meta( $logo_id, '_wp_attachment_image_alt', true );
				}
			} else {
				$merged_atts['logo'] = 0;
			}
		}

		$atts = $merged_atts;

		ob_start();
		include STRUCTURED_CONTENT_PLUGIN_DIR . 'templates/shortcodes/local-business.php';
		$output = ob_get_contents();
		ob_end_clean();

		return $output;

	}

Code file location:

structured-content/structured-content/includes/class-structuredcontent-register-shortcodes.php

Conclusion

Now that you’ve learned how to embed the Structured Content (JSON-LD) #wpsc 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 *