Pregunta

I have this script

<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<th>ID product</th>
</tr>
<?php
    $query_args = array( 'post_type' => 'product', 'posts_per_page' => 1 );
    $loop = new WP_Query( $query_args );
    if ( have_posts() ) while ( $loop->have_posts() ) : $loop->the_post(); global $_product;
?>
    <tr>
        <td><?php echo $_product->get_the_ID(); ?></td>
    </tr>
<?php endwhile; ?>
</table>

But product is not showing. I turned debug ON (True) but get nothing (no errors).

Thank you

¿Fue útil?

Solución

Made some changes:

<?php
    global $_product;
    $args = array( 'post_type' => 'product', 'posts_per_page' => 1 );
    $loop = new WP_Query($args);
    while ($loop->have_posts()) : $loop->the_post();
 ?>

    <product>
    <tr>
        <td><ITEM_ID><?php echo the_ID(); ?></ITEM_ID></td>
        <td><PRODUCTNAME><?php the_title_rss() ?></PRODUCTNAME></td>
<td><?php if (get_option('rss_use_excerpt')) : ?>
        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php endif; ?></td>
        <td><URL><?php the_permalink_rss() ?></URL></td>
        <td><PRICE_VAT><?php echo jigoshop_price($_product['get_price']); ?></PRICE_VAT></td>
        <td><CATEGORYTEXT><?php echo get_option('product_type') ?></CATEGORYTEXT></td>
        <td><EAN><?php echo the_ID(); ?></EAN></td>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
    </tr></product>
<?php endwhile; ?>
</table>

Script show price, but for all products give me € 0,00. Why? Where is my Bug?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top