duanbipu1720 2019-07-16 20:59
浏览 51

店面产品页面获取产品摘要加右浮动它以匹配图像对齐

NOTE: NSFW site, maybe some hot images from eBooks covers, no nude but adult romance covers. I have this page that "brings" a product category, reated with this shortcode

[products limit="6" columns="1" category="mf" class="product-shortcode" cat_operator="AND" ]

And left-aligned (float) with this CSS

/*Align images to the left*/
div.columns-1 {
    float: left
}

Ok, I tried this code to get a summary/brief

add_action( 'woocommerce_after_shop_loop_item_title', 'jdn_add_short_description', 9 );
function jdn_add_short_description() {
 // Description linked to product
 $url = get_the_permalink();
 if( $url ) {
 echo '<span class="title-description"><a href="' . $url . '">' . get_the_excerpt() . '</a></span><br />';
 } else {
 echo '<span class="title-description">' . get_the_excerpt() . '</span><br />'; 
 }
}

BUT it gets the summary in ALL pages, not just this one

What I need:

To get a the product summary/brief JUST in this page, right aligned matching the left aligned images, AND get the Headline, Star Rating, Prie and Get it now also right aligned and Up to math the image, so it all keeps aligned.

is this possible via Code, php, Css, shortcode or is a misconfiguration of woocommerce product?

  • 写回答

1条回答 默认 最新

  • doumen1883 2019-07-23 18:06
    关注

    Solved!!! I wrote my own shortcode as follows, and modified the function, which includes an array of desired pages to show the excerpt, now I only have to style the page so it shows only the image to the left and float the text to the right, no problem.

    · Create the function add_action( 'woocommerce_after_shop_loop_item_title', 'car_excerpt_call', 35, 2);

    function car_excerpt_call() { if ( is_page( array( "mf-romance", "mfm-romance", "mmf-romance", "mfmm-romance-2" ) ) ) { echo ''; the_excerpt(); echo ''; } }

    · Upload it theme or plugin dir with a PHP extension o /home/wigigx/sitetest.wigigx.com/wp-content/plugins/add_excerpt_shortcode' · actively register the shortcode within WordPress. o include( get_stylesheet_directory() . '/home/wigigx/sitetest.wigigx.com/wp-content/plugins/add_excerpt_shortcode' ); · The last step is to register the new shortcode with the Shortcode API with the add_shortcode function. o add_shortcode( 'excerpt_call', 'car_excerpt_call' );

    and it works as a charm!!

    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch