Tuesday, March 12, 2019

How to create shortcodes in Wordpress


We need to create  a custom code sniper inside our wordpress, for example add a message with the date and time then the page is open.


1.- Create a function inside funtion.php of our wordpress
function sc_mycustomcodefunction() {
//bla bla bla, custom dode of our funtion
return ‘today will be agreat day’;

2.- Create the shortcode

add_shortcode('SC01', 'sc_mycustomcodefunction');

3.- Inside the page of wordpress call the whostcode following the next sintaxys.


The function that contains the php code is sc_mycustomcodefunction
The shorcode is created with a wordpress function add_shortcode inside function.php
The parameters of the standard wordpress function add_shortcode are: ( <ShorCodeName>,<FunctionName> )
ShorCodeName is SC01 in our exxample
FunctionName is sc_mycustomcodefunction

Saturday, May 23, 2015

Adding #Charts to a website using javascrip with DataBase connection

You have some data in your DataBase that you would like to explode with Charts to offer Analytics solution to your visitors.

One simple way is to use highcharts, a company that has a collection of utilities to paint Charts using a simple script and of course with data base connecction and much more.

$dbcon = mysql_connect("localhost", "bartolo", "******");
mysql_select_db("DATABASE", $dbcon);
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_array($result)) {
   $data[] = "['".$row['name']."',".$row['tot']."]";

$(function () {
        chart: {
            type: 'pie',
            options3d: { enabled: true, alpha: 45, beta: 0 }
        title: { text: 'Chosse the best Broker' },
        tooltip: {
            pointFormat: '{}: <b>{point.percentage:.1f}%</b>'
        plotOptions: {
            pie: {  allowPointSelect: true, cursor: 'pointer', depth: 35,
                dataLabels: { enabled: true, format: '{}' }}
        series: [{
            type: 'pie',             name: 'Browser share',
            data: [  <?php echo join($data, ','); ?> ]



Wednesday, May 13, 2015

Web Scraper

$request_url ='';

// The Regular Expression filter
 $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

 function get_domain($url)
  $pieces = parse_url($url);
  $domain = isset($pieces['host']) ? $pieces['host'] : '';
  if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
   return $regs['domain'];
  return false;

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $request_url); // The url to get links from

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // We want to get the respone

 $result = curl_exec($ch);

 $title = preg_match('/title="(.+)">/', $html, $match);

 foreach($links as $link){
  $pos = strpos($link, '://');
  $exclude = strpos($link, 'google');  //remove google own results

  if ($pos!=0 && $exclude==0){
    $posini = strpos($link, 'http');
    $link = substr($link, $posini);
    echo "<a href='".$link."'>".get_domain($link)."</a> -> ".$link."<br>";




Friday, May 1, 2015

Update joomla metada keywords from MySQL 'update' query


You are too lazy to update keywords from article manager in the backend, and need a quick option to do that without installing any random plugin that do that for you (I found that plugins don't works as you except).


Go to MySQL administrator page and open your SQL windows to write a new SQL query to update your keywords, the joomla table / field where are stored meta about SEO keywords is _content , and the fieldname is "metakey".
Now with that you only need to run that sample SQL query to update SEO keywords.

SQL Query:
UPDATE *_content SET metakey = 'keyword1,'keyword2,'keyword3,'keyword4,'keyword5'
*Take careful that this query will update all your articles, if you would like to make some filter remember to use SQL conditions like WHERE id=x...


Sunday, April 26, 2015

how to rollover on CSS Image


You need to make a rollover on a sprite css image.


You only need to make a ":rollover" class on your master css file like this:
.buttons{background-image:url('../images/sprite.png');background-position:-13px -21px}
.buttons:hover{background-image:url('../images/sprite.png');background-position:-13px -21px}
The tip is to add ":hover" to a different css class, that class will be loaded when the mouse pass over your css image sprite.

Your HTML code remains as:
<li class="buttons">&nbsp;</li>

Monday, February 9, 2015

joomla web too slow load


Your joomla web site spend a lot of time to load, too much time...


Check if your site has been hacked, look at "include" folder file "joomla_rss.php" and rename it of just delete it.

Saturday, January 17, 2015

Connect Excel 32 Bits to MySQL ODBC in 32 BIts under Windows 64 Bits

You are using Windows 7 in 64 bits and MS Excel in 32 Bits, and you are not able to connect Excel to MysQL trought ODBC DNS 64 Bits.

You need to create a ODBC for MySQL in 32 Bits to avoid architecture problems while connection Excel and DS over ODBC.
The Solution is full documented on the next link: