tonytj
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: can't change the css for a plugin from mythemeLöst
Forum: Fixing WordPress
In reply to: Don't understand function extract in this piece of codeGood explained!!
Forum: Fixing WordPress
In reply to: I want to create a shortcodeThis code below is working and placed in contactInfo.php in the folder ContactInfo in folder Plugin.
Is it a better way of doing this then what I have done here ?
I have tvo questions.
First question. Can I get this information from the database insteqad?Second question. If I want to add a picture to each person how do i do that?
<?php
/*
* Plugin Name: WordPress ShortCode
* Description: Create a wordpress contactinfo shortcode
* Version: 1.0
* Author: Tony Johansson
* Author URI: xxx
*///The contactinfo chortcode
add_shortcode( ‘contact’, ‘getContactInfo’ );
function getContactInfo( $atts )
{
$result =””;
extract(shortcode_atts(array(
‘person’ => ‘noName’
),$atts));switch($person)
{
case ‘anna’:
$result = ‘Name: Anna Persson
‘;
$result .= ‘Phone: 08-123465
‘;
$result .= ‘Address: Stigen 55, 123 45 Småstad
‘;
$result .= ‘E-mail: anna.person@telia.com
‘;
break;case ‘bosse’:
$result = ‘Name: Bosse Hult
‘;
$result .= ‘Phone: 08-987654
‘;
$result .= ‘Address: Öken 99, 123 45 Storstad
‘;
$result .= ‘E-mail: bosse.hult@telia.com
‘;
break;case ‘catrin’:
$result = ‘Name: Catrin Ås
‘;
$result .= ‘Phone: 099-55555
‘;
$result .= ‘Address: Kåken 123, 111 22 Mellanstad
‘;
$result .= ‘E-mail: catrin.ås@telia.com
‘;
break;case ‘noName’
$result = ‘No name given’;
break;
}return $result;
}
?>//Tony