{"id":2845,"date":"2011-08-01T16:53:31","date_gmt":"2011-08-01T08:53:31","guid":{"rendered":"http:\/\/www.rockfu.net\/blog\/?p=2845"},"modified":"2011-08-01T17:00:30","modified_gmt":"2011-08-01T09:00:30","slug":"wordpress-wp-ecommerce","status":"publish","type":"post","link":"https:\/\/www.rockfu.net\/blog\/2011\/08\/website\/wordpress\/wordpress-wp-ecommerce\/","title":{"rendered":"wordpress wp ecommerce last product"},"content":{"rendered":"<p>wordpress \u8a2d\u8a08theme \u6642\u9700\u8981\u5728\u9996\u9801\u53d6\u5f97wp ecommerce \u7684\u6700\u65b0\u7522\u54c1\u8cc7\u6599\uff0c\u53ef\u4ee5\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff0c\u8f38\u51fa\u5716\u7247\uff0c\u548ctitle\uff0c\u7db2\u4e0a\u627e\u6c92\u4ec0\u9ebc\u8cc7\u6599\uff0c\u53ea\u597d\u81ea\u5df1\u5728widget \u6539\u4e00\u4e0b\u90a3\u4f86\u7528<\/p><div class=\"rockf-content\" id=\"rockf-339527291\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5237544886808594\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5237544886808594\" \ndata-ad-slot=\"6353985797\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n<p>[php]<br \/>\n\tglobal $wpdb;<br \/>\n\t$args = wp_parse_args( (array)$args, array( &#8216;number&#8217; => 5 ) );<\/p>\n<p>\t$number  = 3;<br \/>\n\t$image  = true;<\/p>\n<p>\t\t$width = 150;<\/p>\n<p>\t\t$height = 150;<\/p>\n<p>\t$latest_products = get_posts( array(<br \/>\n\t\t&#8216;post_type&#8217;   => &#8216;wpsc-product&#8217;,<br \/>\n\t\t&#8216;numberposts&#8217; => $number,<br \/>\n\t\t&#8216;orderby&#8217;     => &#8216;post_date&#8217;,<br \/>\n\t\t&#8216;post_parent&#8217; => 0,<br \/>\n\t\t&#8216;post_status&#8217; => &#8216;publish&#8217;,<br \/>\n\t\t&#8216;order&#8217;       => &#8216;DESC&#8217;<br \/>\n\t) );<br \/>\n\t$output = &#8221;;<\/p>\n<p>\tif ( count( $latest_products ) > 0 ) {<br \/>\n\t\t$output .= &#8216;<\/p>\n<ul class=\"wpsc-latest-products\">&#8216;;<br \/>\n\t\tforeach ( $latest_products as $latest_product ) {<br \/>\n\t\t\t$output .= &#8216;<\/p>\n<li class=\"wpsc-latest-product\">&#8216;;<br \/>\n\t\t\t\/\/ Thumbnails, if required<br \/>\n\t\t\tif ($image) {<br \/>\n\t\t\t\t$output .= &#8216;<\/p>\n<div class=\"item_image\">&#8216;;<br \/>\n\t\t\t\t$output .= &#8216;<a href=\"' . wpsc_product_url( $latest_product->ID, null ) . &#8216;&#8221;>&#8217;;<br \/>\n\t\t\t\t$attached_images = (array)get_posts( array(<br \/>\n\t\t\t\t\t&#8216;post_type&#8217;   => &#8216;attachment&#8217;,<br \/>\n\t\t\t\t\t&#8216;numberposts&#8217; => 1,<br \/>\n\t\t\t\t\t&#8216;post_status&#8217; => null,<br \/>\n\t\t\t\t\t&#8216;post_parent&#8217; => $latest_product->ID,<br \/>\n\t\t\t\t\t&#8216;orderby&#8217;     => &#8216;menu_order&#8217;,<br \/>\n\t\t\t\t\t&#8216;order&#8217;       => &#8216;ASC&#8217;<br \/>\n\t\t\t\t) );<br \/>\n\t\t\t\t$attached_image = $attached_images[0];<br \/>\n\t\t\t\tif ( $attached_image->ID > 0 )<br \/>\n\t\t\t\t\t\t$output .= &#8216;<img decoding=\"async\" src=\"' . wpsc_product_image( $attached_image-\/>ID, $width, $height ) . &#8216;&#8221; title=&#8221;&#8216; . $latest_product->post_title . &#8216;&#8221; alt=&#8221;&#8216; . $latest_product->post_title . &#8216;&#8221; \/>&#8217;;<br \/>\n\t\t\t\telse<br \/>\n\t\t\t\t\t$output .=&#8217;<img decoding=\"async\" class=\"no-image\" id=\"product_image_'.wpsc_the_product_id().'\" alt=\"No Image\" title=\"'.wpsc_the_product_title().'\" src=\"'.WPSC_URL.'\/wpsc-theme\/wpsc-images\/noimage.png\" width=\"' . $width . '\" height=\"' . $height . '\" \/>&#8216;;<\/p>\n<p>\t\t\t\t$output .= &#8216;<\/a>&#8216;;<br \/>\n\t\t\t\t$output .= &#8216;<\/div>\n<p>&#8216;;<br \/>\n\t\t\t}<br \/>\n\t\t\t\/\/ Link<br \/>\n\t\t\t$output .= &#8216;<a href=\"' . wpsc_product_url( $latest_product->ID, null ) . &#8216;&#8221; class=&#8221;wpsc-product-title&#8221;>&#8217;.stripslashes( $latest_product->post_title ).&#8217;<\/a>&#8216;;<br \/>\n\t\t\t$output .= &#8216;<\/li>\n<p>&#8216;;<br \/>\n\t\t}<br \/>\n\t\t$output .= &#8220;<\/ul>\n<p>&#8220;;<br \/>\n\t}<br \/>\n\techo $output;<br \/>\n[\/php]<\/p>\n<div class=\"rockf-after\" id=\"rockf-1994721268\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5237544886808594\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5237544886808594\" \ndata-ad-slot=\"6353985797\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>wordpress \u8a2d\u8a08theme \u6642\u9700\u8981\u5728\u9996\u9801\u53d6\u5f97wp ecommerce \u7684\u6700\u65b0\u7522\u54c1\u8cc7\u6599\uff0c\u53ef\u4ee5\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff0c &hellip; <a href=\"https:\/\/www.rockfu.net\/blog\/2011\/08\/website\/wordpress\/wordpress-wp-ecommerce\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80<span class=\"screen-reader-text\"> &#8220;wordpress wp ecommerce last product&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[273,139],"tags":[500,750,499],"class_list":["post-2845","post","type-post","status-publish","format-standard","hentry","category-php","category-wordpress","tag-last-product","tag-wordpress","tag-wp-ecommerce"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/prNEE-JT","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/posts\/2845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/comments?post=2845"}],"version-history":[{"count":6,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/posts\/2845\/revisions"}],"predecessor-version":[{"id":2851,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/posts\/2845\/revisions\/2851"}],"wp:attachment":[{"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/media?parent=2845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/categories?post=2845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rockfu.net\/blog\/wp-json\/wp\/v2\/tags?post=2845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}