Vertical marquee Shortcode

Below, you’ll find a detailed guide on how to add the Vertical marquee 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 Vertical marquee Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Vertical marquee Plugin and the shortcodes it provides:

Plugin Icon
Vertical marquee plugin

"Vertical Marquee Plugin is a dynamic tool for WordPress that enables scrolling text or image vertically on your website. It's perfect for news tickers, announcements, or promotions."

★★★★✩ (7) Active Installs: 3000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [vertical-marquee]

Vertical marquee [vertical-marquee] Shortcode

The Vertical Marquee Plugin shortcode is designed to fetch and display scrolling text from a database. It uses specific settings and groups to customize the scrolling text. This shortcode retrieves data based on the ‘setting’ and ‘group’ attributes. It then formats the data into a scrolling marquee, with parameters like scroll amount, delay, direction, and style derived from the settings. If no records are available, it displays an error message.

Shortcode: [vertical-marquee]

Parameters

Here is a list of all possible vertical-marquee shortcode parameters and attributes:

  • setting – Defines the settings for the marquee, can be 1, 2 or default
  • group – Specifies the group for the marquee text

Examples and Usage

Basic example – The basic usage of the shortcode for the vertical marquee plugin involves defining the setting and group parameters.

[vertical-marguee setting="1" group="widget"]

Advanced examples

Using the shortcode with setting 2 and a different group. The marquee will be displayed with the settings defined in ‘vm_setting2’ and the data will be fetched based on the group ‘header’.

[vertical-marguee setting="2" group="header"]

Using the shortcode without defining a specific setting. In this case, the marquee will be displayed with the default settings defined in ‘vm_setting3’ and the data will be fetched based on the group ‘footer’.

[vertical-marguee group="footer"]

Using the shortcode with setting 1 and without defining a specific group. The marquee will be displayed with the settings defined in ‘vm_setting1’ and the data will be fetched based on the default group.

[vertical-marguee setting="1"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'vertical-marguee', 'vm_shortcode' );

Shortcode PHP function:

                    function vm_shortcode( $atts ) 
{
	global $wpdb;
	//[vertical-marguee setting="1" group="widget"]
	if ( ! is_array( $atts ) )	{ return ''; }
	$setting = $atts['setting'];
	$group = $atts['group'];
	switch ($setting) 
	{ 
		case 1: 
			$vm_setting = get_option('vm_setting1');
			break;
		case 2: 
			$vm_setting = get_option('vm_setting2');
			break;
		default:
			$vm_setting = get_option('vm_setting3');
	}
	list($vm_scrollamount, $vm_scrolldelay, $vm_direction, $vm_style) = explode("~~", $vm_setting);
	
	// Database query
	$what_marquee = "";	
	$link = "";
	$sSql = "select vm_text,vm_link from ".WP_VM_TABLE." where vm_group = %s ";
	$sSql = $sSql . " and (`vm_date` >= NOW())";
	$sSql = $sSql . " ORDER BY vm_id desc";
	
	$sSql = $wpdb->prepare($sSql, $group);
	
	$data = $wpdb->get_results($sSql);
	if ( ! empty($data) ) 
	{
		$cnt = 0;
		$vsm = "";
		foreach ( $data as $data ) 
		{
			$link = $data->vm_link;
			if($cnt==0) 
			{  
				if($link != "" && $link != "#") { $vsm = $vsm . "<a target='_blank' href='".$link."'>"; } 
				$vsm = $vsm . stripslashes($data->vm_text);
				if($link != "" && $link != "#") { $vsm = $vsm . "</a><br />"; }
			}
			else
			{
				$vsm = $vsm . "   <br /><br />   ";
				if($link != "" && $link != "#") { $vsm = $vsm . "<a target='_blank' href='".$link."'>"; } 
				$vsm = $vsm . stripslashes($data->vm_text);
				if($link != "" && $link != "#") { $vsm = $vsm . "</a><br />"; }
			}			
			$cnt = $cnt + 1;
		}
		
		// Marquee text display
		$what_marquee = $what_marquee . "<div style='padding:3px;'>";
		$what_marquee = $what_marquee . "<marquee style='$vm_style' scrollamount='$vm_scrollamount' scrolldelay='$vm_scrolldelay' direction='$vm_direction' onmouseover='this.stop()' onmouseout='this.start()'>";
		$what_marquee = $what_marquee . $vsm;
		$what_marquee = $what_marquee . "</marquee>";
		$what_marquee = $what_marquee . "</div>";
	}
	else
	{
		$what_marquee = __('Please check your short code, no records available.', 'vertical-marquee-plugin');	
	}
	return $what_marquee;
}
                    

Code file location:

vertical-marquee-plugin/vertical-marquee-plugin/vertical-marquee-plugin.php

Conclusion

Now that you’ve learned how to embed the Vertical marquee 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.

Comments

Leave a Reply

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