• I have places in my blog which display a price of a tour offered. The tour costs change frequently and this value is on many different pages. Is there a way I can import the value from a spreadsheet which will update the value on my blog in all of the places it appears.
    Other words, a data value appears in many places on my blog. That data value changes. When it changes I would like to change it in one place and show the changed value in all of the places it appears in the blog.
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • This does not sound (to me, at least) like a task that can be handled with an out-of-the-box solution. Depending on the number of different prices, and the frequency of changes, you might be looking at creating your own database table, with its own code to add, delete, and update entries. Along with that you would need code to retrieve values from the database and insert them into posts.

    If there are not too many values, and you don’t mind changing some code when a value changes, you might get away with something like shortcodes and a single function to set the values in a switch statement. For example, you might use a shortcode like: [tourprice tour=’FourCorners’] and a function which would return the correct price for ‘FourCorners’.

    If all this is greek to you, you might need to contract out the work.

    In case you want to try the quick-and-dirty route, here is the code to put in functions.php. Be careful though, you can disable your site if you make a mistake. Make a backup of functions.php just in case.

    Edit the tour names and prices and add more case statements to suit.

    <?php // [mm-tourprice tour='TourName']
    function mm_tourprice_func($atts) {
    	extract(shortcode_atts(array(
    		'tour' => 'Unknown',
    	), $atts));
       $price = ($tour == '') ? "** ERROR No Tour Name **" : "** ERROR on tour $tour**";
       switch($tour) {
          case 'FirstClass': $price = '$499.95'; break;
          case 'SecondClass': $price = '$222.22'; break;
       }
       return $price;
    }
    add_shortcode('mm-tourprice', 'mm_tourprice_func');
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘import data value from Excel’ is closed to new replies.