Below, you’ll find a detailed guide on how to add the Simple Pull Quote 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 Simple Pull Quote Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Simple Pull Quote Plugin and the shortcodes it provides:
"Simple Pull Quote is a WordPress plugin allowing you to add stylistically significant quotes in your posts. Simple, user-friendly, it enhances content readability."
- [pullquote]
- [quote]
- [quote1]
- [quote2]
Simple Pull Quote [pullquote] Shortcode
The Simple Pull Quote shortcode allows you to create stylized quotes within your content. The shortcode ‘pullquote’ calls the function ‘getSimplePullQuote’. This function formats the quote content, applying a class for style. It then wraps the content in a div with the class ‘simplePullQuote’, enhancing the visual appeal of your quote.
Shortcode: [pullquote]
Parameters
Here is a list of all possible pullquote shortcode parameters and attributes:
class
– Defines the CSS class of the pull quote.
Examples and Usage
Basic example – A simple shortcode to display a pull quote with default right alignment.
[pullquote]Your quote here[/pullquote]
Advanced examples
Using the shortcode to display a pull quote with a custom class. The class attribute allows you to customize the appearance of the pull quote with CSS.
[pullquote class="left"]Your quote here[/pullquote]
Using the shortcode to display a pull quote with nested shortcodes. This allows you to include other shortcodes within the pull quote.
[pullquote class="center"][another_shortcode]Your quote here[/another_shortcode][/pullquote]
PHP Function Code
In case you have difficulties debugging what causing issues with [pullquote]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('pullquote', 'getSimplePullQuote');
Shortcode PHP function:
function getSimplePullQuote( $atts, $content = null ) {
$output = '';
$pull_quote_atts = shortcode_atts( array(
//'quote' => 'My Quote',
'class' => 'right',
), $atts );
$content = wpautop(trim($content));
return '<div class="simplePullQuote ' . wp_kses_post( $pull_quote_atts[ 'class' ] ) . '">'. do_shortcode($content) .'</div>';
}
Code file location:
simple-pull-quote/simple-pull-quote/simple-pull-quote.php
Simple Pull Quote [quote] Shortcode
The Simple Pull Quote shortcode is a functional tool that retrieves and displays custom field data. The shortcode ‘quote’ triggers the ‘getQuote’ function. This function accesses the global $post object and fetches the value of the custom field “quote”. The retrieved quote is then styled and returned within a div class “simplePullQuote”. This allows for easy customization and styling of the quote.
Shortcode: [quote]
Examples and Usage
Basic example – This shortcode displays a simple pull quote from the post meta data, which is styled with the “simplePullQuote” CSS class.
[quote]
Advanced examples
Using the shortcode to display a pull quote from a specific post by providing the post ID as an argument. The quote will be fetched from the post meta data of the provided post ID.
[quote id=15]
Using the shortcode to display a pull quote from a specific post and also specifying a custom CSS class for the quote. The quote will be fetched from the post meta data of the provided post ID and will be styled with the provided CSS class.
[quote id=15 class="customClass"]
Please note that these advanced usage examples assume that the ‘getQuote’ function has been modified to accept and handle ‘id’ and ‘class’ parameters. If it has not been, these examples will not work as expected.
PHP Function Code
In case you have difficulties debugging what causing issues with [quote]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('quote', 'getQuote');
Shortcode PHP function:
function getQuote(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
Code file location:
simple-pull-quote/simple-pull-quote/simple-pull-quote.php
Simple Pull Quote [quote1] Shortcode
The Simple-Pull-Quote plugin shortcode ‘quote1’ retrieves a custom field from a post. This shortcode calls the function ‘getQuote1’, which fetches the value of the custom field “quote1” from the current post. The value is then wrapped in a div with the class “simplePullQuote” for styling.
Shortcode: [quote1]
Examples and Usage
Basic example – The shortcode ‘quote1’ is used to fetch a custom field associated with a post. This custom field is displayed within a div with the class ‘simplePullQuote’.
[quote1]
Advanced examples
Here, we will modify the function to accept parameters. The parameters can be used to fetch specific custom fields and apply different CSS classes.
function getQuote1($atts){
global $post;
$attributes = shortcode_atts( array(
'field' => 'quote1',
'class' => 'simplePullQuote'
), $atts );
$my_custom_field = get_post_meta($post->ID, $attributes['field'], true);
return ''.$my_custom_field.'';
}
add_shortcode('quote1', 'getQuote1');
With the modified function, you can now use the shortcode ‘quote1’ with two parameters: ‘field’ and ‘class’. The ‘field’ parameter is used to specify the custom field to fetch and the ‘class’ parameter is used to specify the CSS class to apply to the div.
[quote1 field="quote2" class="myCustomClass"]
In this example, the shortcode ‘quote1’ is fetching the custom field ‘quote2’ and applying the CSS class ‘myCustomClass’ to the div.
PHP Function Code
In case you have difficulties debugging what causing issues with [quote1]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('quote1', 'getQuote1');
Shortcode PHP function:
function getQuote1(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote1", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
Code file location:
simple-pull-quote/simple-pull-quote/simple-pull-quote.php
Simple Pull Quote [quote2] Shortcode
The Simple Pull Quote plugin shortcode ‘quote2’ is designed to fetch and display custom fields from your posts. Using ‘quote2’, the shortcode retrieves the corresponding custom field value, wraps it within a div, and applies the ‘simplePullQuote’ CSS class for styling.
Shortcode: [quote2]
Examples and Usage
Basic example – A simple usage of the ‘quote2’ shortcode to display a pull quote that has been stored in the custom field ‘quote2’ of a post.
[quote2 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [quote2]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('quote2', 'getQuote2');
Shortcode PHP function:
function getQuote2(){
global $post;
$my_custom_field = get_post_meta($post->ID, "quote2", true);
/* Add CSS classes to the pull quote (a.k.a. Style the thing!) */
return '<div class="simplePullQuote">'.$my_custom_field.'</div>';
}
Code file location:
simple-pull-quote/simple-pull-quote/simple-pull-quote.php
Conclusion
Now that you’ve learned how to embed the Simple Pull Quote Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply