• I’m completely new to WordPress. I read in the book Professional WordPress Design and Development by Brad Williams, david damstra and Hal Stern.

    I have earlier worked a lot with asp.net Webbform but WordPress is very different and I found it difficult.

    I’m now working on a blog for me.
    I want to create some contact info about me in each post I do so a good solution is to use a shortcode.

    So I want to use something like [Contact name=”xxx”]
    where name is the person that owned the blogg.

    I have some questions about that.
    1. In what file should I put the shortcode?
    Can I just put it under a file named contact.php in a folder called contact in the plugin folder ?

    2. How to I best get the contact information such as mailaddress an telephonenumber from the database.

    //Tony

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi ?? ,

    You might get some help with below plugin:

    https://www.ads-software.com/plugins/shortcodes-generator/

    you dont need to create contact info, your profile is linked with each post you do.

    have you tried doing a post on your wordpress yet?

    Thread Starter tonytj

    (@tonytj)

    This 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: [email protected]
    ‘;
    break;

    case ‘bosse’:
    $result = ‘Name: Bosse Hult
    ‘;
    $result .= ‘Phone: 08-987654
    ‘;
    $result .= ‘Address: ?ken 99, 123 45 Storstad
    ‘;
    $result .= ‘E-mail: [email protected]
    ‘;
    break;

    case ‘catrin’:
    $result = ‘Name: Catrin ?s
    ‘;
    $result .= ‘Phone: 099-55555
    ‘;
    $result .= ‘Address: K?ken 123, 111 22 Mellanstad
    ‘;
    $result .= ‘E-mail: [email protected]
    ‘;
    break;

    case ‘noName’
    $result = ‘No name given’;
    break;
    }

    return $result;
    }
    ?>

    //Tony

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I want to create a shortcode’ is closed to new replies.