Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Friday, December 25, 2020

How to text spin using a wordpress shorcut

You need to create random text but with sense, for example, you have a web page that have thousand of pages and you would like to create text automatically using text spin technique.

1.- Create a new function inside your Wordpress "Snippets" plugin.

function fun_textspin() {
class Spintax
public function process($text)
return preg_replace_callback(
array($this, 'replace'),
public function replace($text)
$text = $this->process($text[1]);
$parts = explode('|', $text);
return $parts[array_rand($parts)];
$spintax = new Spintax();
$string = '{Hello|Howdy|Hola} to you, {Mr.|Mrs.|Ms.} Smith|Williams|Davis}!';
return $spintax->process($string);

add_shortcode( 'sc_textspin','fun_textspin' );


2.- add the following Shorcut to your wordpress page.

<!-- wp:paragraph -->


<!-- /wp:paragraph -->


Thursday, December 3, 2020

How to connect to Wordpress SQL using shortcuts


Yo need to access to any database table connected to your wordpress or maybe an external one to extract any information and process it.


Use this TestSQLand add is to your wordpress functions.php of "Code Snipper" plugin:

function TestSQL_Function( $atts ) {
$link = mysqli_connect("localhost", "user", "****", "DATABASENAME");
$sql = "SELECT * FROM table";
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_array($result)){
            $line = $line.$row['fielname1']."(".$row['fieldname2'].")";
return $line;
        // Free result set
    } else{
        return "No records matching your query were found.";
} else{
    return "ERROR: Could not able to execute $sql. " . mysqli_error($link);
// Close connection
add_shortcode( 'TestSQL', 'TestSQL_Function' );

Now, you only need to add the wordpress shortcut [TestSQL] in your wordpres post or page.