<strong>Online Price</strong>:$ 20.00<br> <span style="color: red;">Your Price</span>:$ 17.91<br> Check <a href="/go/" target="_blank">Puma Tshirt</a> to get your deal!</p> HTML: this is the html code Is that what you looking for
I understand what you want. But the price is already generated into my wordpress post. A plugin called WProbot is generating those prices. So each post/article has his own price already in the html
I want to creat a small snippet of php to get that price Then I'll paste this php inside my html link. I'll show you an example. This is my sharing link on pinterest. This is my link <a href="http://pinterest.com/pin/create/button?url=<?php echo get_permalink() ?>&media=<?php $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'large', true); echo $image_url[0]; ?>&description=<?php the_title(); ?> via @cheetahreviews <?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo '%23' . $tag->name . ' '; } } ?>"> Pin It</a> PHP: But when a visitor comes to my page the link is already generated and looks like that http://pinterest.com/pin/create/button?url=http://hytyeview.org/puma-logo-tee-young/&media=http://huyhyview.org/wp-content/uploads/2012/05/puma-tshirt-small.jpg&description=Puma%20logo%20tee%20for%20young%20via%20@chhyhiews%20%23addidas%20%23nike%20%23puma%20%23shoes%20%23tshirt HTML: When they click the Pinterest share all my page info are going to show on pinterest BUT IM ONLY MISSING THE PRICE.
Let me see if I follow this. You creating a SEPARATE php script which you wish to display the price that is listed on a different page? So basically you would have to fetch the HTML content... then extract the price to have access to it, right?
its hard to explain because of my english but I'll try I put those php "snippets" in my wordpress template. Everytime the page is loading those codes/snippets are loaded in those pages. So every code/snippet is on those pages. So if I get the PHP code to parse the price between the 2 strings below and paste it in my template, the php code will parse the price on each dynamicly. like this PHP for example <?php echo get_permalink() ?> PHP: is loaded on every page but getting the permalink for the page that is loading
Is get_permalink() defined by your WordPress Plugin? Or is that your code? If it's defined by your PlugIn and your PlugIn defines the Price you should be able to use the Variable for the price and not have to worry about extracting.
get permalink is defyned by Wordpress. The price is the plugin that defines it. but I cant find it. It will be easier to extract the price because the plugin generating an wordpress shortcode and this shortcode is generating the price. Also each shortcode is different because the price comes from amazon and the shortcode contains the ASIN(product number). So the shortcode are not unique
Without seeing the PHP source I couldn't tell you how to access the Price. The only way I can suggest is to Launch a request to download the HTML page. Then extract the price. It's hardly the proficient way to do this...but It will work. <?php $url = "http://some-url/to/the/page/with-the-price.html"; // // Fetch web page // $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $myHtmlPrice = curl_exec($ch); curl_close($ch); // // Extract Price // $matches = array(); preg_match('/<span style="color: red;">Your Price<\/span>:\$ (.*)<br>/', $myHtmlPrice, $matches); $myPrice = $matches[1]; // // Outout // print "The price is: $myPrice"; ?> PHP:
no even that dosent work I can't send you the plugin because it exeed the upload limit. So I guess I'll do it without the price. Thank you very much
I FINALLY FOUND HOW TO DO IT. OOOOOHHHH MY GOD it was so stupid and easy.(It was 3 days I was looking for a solution) I went in my template and added this <?php $postprice = '{price}'; ?> PHP: the {price} tag is generating the tag for each post. Then I went in my general template and added to the pinterest link <?php echo $postprice; ?> PHP: So now it shows me the price on I want on each post and in the share link. The only problem is the {price} is generated by php also. So when it generates the post I get a blan page because its adding a space(I dont know why) like that <?php $ postprice = '$ 17.91'; ?> PHP: Do you have an idea why???
You want to get rid of the space inbetween $ and 17.91? If so use this: $postprice = "{price}"; $postprice = str_replace(" ", "", $postprice); PHP: Or are you talking about the space between $ and postprice?
I'm not looking at your code which makes this terribly difficult. Nor do I know what you are using. If there is a space in your variable the solution is to simply delete the space that you added. If you are suggesting that a PHP script is outputting your PHP code and is placing the space there.. double check your template and make sure you have the code wrapped in the <?php ?> tags.
I think buddy your programming knowledge is very basic, you should contact a pro to fix your problem.