Monday, 16 April 2018

How To Create Shortcode In WordPress with parameters?



<?php
### the shortcode code add in theme’s functions.php file  ###
// "do_shortcode" but without the wrapping <p> of Shortcodes
function do_shortcode_boc($content) {
 $array = array (
        '<p>[' => '[',
        ']</p>' => ']',
        ']<br />' => ']'
    );
$content = strtr($content, $array);
$content = do_shortcode($content);
    return $content;
}

function shortcode_shortcodename($atts, $content = null) {   
$atts = shortcode_atts(
array(
'title' => '',
'image' => '',
        ), $atts);

$title = $atts['title'] ? $atts['title'] : '';
$image = $atts['image'] ? $atts['image'] : '';

$str = '<li>
<div class="icon_item">
<img src="'.$image.'">
<p>'.html_entity_decode($title).'</p>
<div class="icon_overlay">
<p>'.do_shortcode($content).'</p>
</div>
</div>
</li>';
return $str;
}
add_shortcode('shortcodename', 'shortcode_shortcodename');

?>

##### Using below code to display shortcode detail  #####

[shortcodename title="my title" image="example.jpg"]
<div>
<p> Shortcode content </p>
</div>
[/shortcodename]

##### OR #####

<?php
echo do_shortcode('[shortcodename]');
?>

Saturday, 3 February 2018

Set only first letter capital other in lowercase in PHP SQL

$sql = "SELECT concat(left(emp_name,1),substring(lower(emp_name),2)) as emp_name FROM employee";

Input    : "Raj Kumar"
Output : "Raj kumar"

Friday, 5 January 2018

WAMP: Missing http://localhost/ in urls , wrong WAMP projects url

1. Open wamp/www/index.php in Change

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'off' ? true : false);
To
$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'on' ? true : false);

OR

2. From Wamp

  1. Right click on wamp icon on tray on the right.

  2. Go to "wamp settings"

  3. Enable "Add localhost in URL"



Friday, 29 December 2017

Contact Form 7 Data POST


How to pass/post Contact Form 7 Data another storage or API?

Download  Contact Form 7 Data POST Plugin and write your custom code in plugin file then you can pass data easily...🌝


Monday, 25 September 2017

Uncaught Error: Syntax error, unrecognized expression: [href=#] in ordpress




To temporarily solution
Until your theme developers release a fixed version,
you can add the following code snippet into your theme functions.php file

------------------------------------------------------------------------------------

add_action( 'wp_enqueue_scripts', 'load_old_jquery', 100 );
function load_old_jquery() {
if ( ! is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" ), false, '1.11.3' );
wp_enqueue_script( 'jquery' );
}
}