I am slightly stuck. The template i am using has a custom post type called products. When i add posts/pages here, i can get them displayed using a widget code in a page.
The widget displays the content entered into custom fields, but i can’t for the life of me work out how to modify the code in order to display the content from the custompost type Content section. Any insight?
This is the code from the shortcodes.php file which produces the widget.
$count_posts = wp_count_posts('product');
$published_posts = $count_posts->publish;
$out ='';
$out .=' <div class="pricing-table">';
$out .= '<ul>';
$counter = 0;
while ( have_posts() ) : the_post();
$counter++;
$product_price = get_post_meta($post->ID,'_product_price',true);
$out .= '<li class="heading-column '.$class_heading.' color'.$counter.'">';
$out .= '<h3>'.get_the_title().'</h3>';
$out .= '<h5>';
$out .= $currency ? $currency : "$";
$out .= $product_price;
if ($billing_cycle == "none") {
$out .= "";
} else {
$out .= ' per '.$billing_cycle;
}
$out .= '</h5>';
$out .= '</li>';
endwhile;
$out .= '</ul>';
$out .= '<div class="clear"></div>';
$out .= '<ul>';
while ( have_posts() ) : the_post();
$product_url = get_post_meta($post->ID,'_product_url',true);
$product_feature = get_post_meta($post->ID,'_product_feature',true);
$features_list = explode(",",$product_feature);
$counter++;
$out .= '<li class="pric-column '.$class_column;
if ($counter%$columns==0) $out .= '-last';
$out .= '">';
foreach ($features_list as $flist) {
$out .= '<ul class="feature-list">';
$out .= '<li>'.$flist.'</li>';
}
$out .= '<li class="last">';
$out .= '<a class="button" href="'.$product_url.'"><span>'.$product_button_text.'</span></a>';
$out .= '</li>';
$out .= '</ul>';
endwhile;wp_reset_query();
$out .= '</ul>';
$out .= '</div>';
return '[raw]'.$out.'[/raw]';
}
your code doesn’t work because
the loop
doesn’t get filled.There for it will do the default loop of the page. (if it hasn’t run already that is)
Also you do stuff that does nothing like
$published_posts
.You should create a custom loop with
WP_Query
.A little help to get you started:
This should get you started.
If you need any help, let me know!