Magical Posts Display Shortcode

Below, you’ll find a detailed guide on how to add the Magical Posts Display Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Magical Posts Display Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Magical Posts Display Plugin and the shortcodes it provides:

Plugin Icon
Magical Posts Display – Elementor Advanced Posts widgets

"Magical Posts Display is an advanced Elementor widget plugin. It enhances your WordPress site with dynamic post display features, offering a variety of customizable options to showcase your content."

★★★★✩ (8) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [magical-post]

Magical Posts Display [magical-post] Shortcode

The Magical Posts Display shortcode is designed to fetch and display posts based on specific attributes. Utilizing the ‘mp_display__shortcode’ function, it allows you to display a single post by its ‘id’. It provides two layout options – grid or list – determined by the ‘posts_card_type’. If no posts are found, it displays a ‘No post found!’ message.

Shortcode: [magical-post]


Here is a list of all possible magical-post shortcode parameters and attributes:

  • id – The unique ID for the specific post to display.

Examples and Usage

Basic example – Display a magical post using its unique ID

[magical-post id=1 /]

Advanced examples

Display a magical post using its unique ID and customize the post display style to grid or list. If the style is not found, it will default to grid.

[magical-post id=1 style=grid /]

Display a magical post using its unique ID and customize the post display style to list. If the style is not found, it will default to grid.

[magical-post id=1 style=list /]

Note: In the above examples, replace ‘1’ with the actual ID of the magical post you want to display. The ‘style’ attribute is optional and can be either ‘grid’ or ‘list’. If not specified, the default style ‘grid’ will be used.

PHP Function Code

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

Shortcode line:


Shortcode PHP function:

function mp_display__shortcode($atts, $content = null){
global $post;
    $mp_display_atts = shortcode_atts( array(
        'id'=> '',
    ), $atts );

	//Query args
	$args = array(
		'post_type'  		=>	'mp-display',
		'post_status'  		=>	'publish',
		'posts_per_page' 	=> 1,
		 'p'                => $mp_display_atts['id']
	//start WP_Query
	$loop= new WP_Query($args);

	<?php if ($loop -> have_posts() ) : ?>
	<?php while ( $loop->have_posts()) :  $loop->the_post();

	//slider style one meta 
	$posts_card = get_post_meta( get_the_ID(), 'posts_card', 1 );
	$mp_posts_card_type =  !empty( $posts_card[0]['posts_card_type'])  ? $posts_card[0]['posts_card_type'] : 'grid';
<div class="mgps mgps-<?php echo get_the_ID(); ?>">
		do_action('mgp_card_style_display', get_the_ID() );
    if($mp_posts_card_type == 'grid'){
      do_action( 'card_grid_post_display', get_the_ID() );
      do_action( 'card_list_post_display', get_the_ID() );

	<?php endwhile; ?> 
<?php wp_reset_postdata(); ?>
 <?php else: ?>
 <div class="no-mp-display">
 <h2><?php esc_html_e('No post found!','magical-posts-display'); ?></h2>
 <?php endif; ?>

 $mp_display_shortcode = ob_get_clean(); 
return $mp_display_shortcode;

Code file location:



Now that you’ve learned how to embed the Magical Posts Display Plugin shortcode, 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

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