SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jul 2012
    0 Post(s)
    0 Thread(s)

    Question Wordpress PHP snipet to shortcode.

    The following php code when added to the html of a post prints the folowing:

    Price/per: [custom field :'item price'] €

    or if the site is in greek (qtranslate):

    Τιμή/τεμ: [custom field :'item price] €

    PHP Code:
    <?php $price get_post_meta(get_the_ID(),'item_price',true);?>
    <span align="center">'<?php _e("<!--:en-->Price/per: <!--:--><!--:EL-->Τιμή/τεμ: <!--:-->"); ?><?php echo $price;?><?php echo "\xE2\x82\xAc";?>'</span>

    What i'd like to do is create a shortcode so i don't have to go to html and copy paste this snippet in every post. Instead i'd like to type [price] and simply set a value to my custom field.
    The custom field is also displayed in the categories and soon in the store page. So i'd like to automate this as much as possible. I've tried to make the shortcode in several ways and i've tried several insert php to post plugins... All my function.php attempts result in a white screen and the site going unresponsive, the only way to recover is to ftp a copy of function.php to replace my changes.. No empty space is left at the end btw.

    The site is mainly empty due to small issues but the link is <snip>

    Another issue i have, is there any way to automatically fill in the style variable when adding an image to post? Everytime i have to click, image properties, advanced and type into styles : border-radius:10px;
    Last edited by TechnoBear; Jan 7, 2013 at 05:48. Reason: Link removed at member's request

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts