Scheduler › Forums › BirchPress Scheduler › Displaying Service Post Content and Pricing
Tagged: frontend service posts price
This topic contains 5 replies, has 3 voices, and was last updated by itwd.ian 10 years, 9 months ago.
-
AuthorPosts
-
July 12, 2013 at 7:40 am #2332
I’ve been trying to figure out how to display the custom services posts with title, description and pricing and I’ve been successful displaying services with title and description but can’t seem to display the price.
Below is my current code to display all services with title and description and my attempt at displaying the price.
<?php $tax_query = array( 'relation' => 'AND' ); $args = array( 'post_type' => 'birs_service', 'tax_query' => $tax_query, 'posts_per_page' => 100 ); $custom_loop = new WP_Query( $args ); if ( $custom_loop->have_posts() ) : while( $custom_loop->have_posts() ) : $custom_loop->the_post(); ?> <article class="spa_service"> <h1><?php the_title(); ?></h1> <p><?php the_content(); ?></p> <p><?php get_post_meta($post->ID, 'birs_service_price'); ?></p> <br style="clear:both"> </article> <?php endwhile; else : _e('Sorry, No Services Available Currently.'); endif; wp_reset_query(); ?>
July 12, 2013 at 6:11 pm #2333Hi Jon,
The price meta field should be ‘_birs_service_price’ other than ‘birs_service_price’.
If you have any other questions, please feel free to contact us.
July 24, 2013 at 7:55 am #2407Hi,
I really like the look of this and have added it to an Advanced Text Widget (one that can handle PHP) my code though does’t show the price either.
here it is:<?php $tax_query = array( 'relation' => 'AND' ); $args = array( 'post_type' => 'birs_service', 'tax_query' => $tax_query, 'posts_per_page' => 100 ); $custom_loop = new WP_Query( $args ); if ( $custom_loop->have_posts() ) : while( $custom_loop->have_posts() ) : $custom_loop->the_post(); ?> <article class="service"> <h6><?php the_title(); ?></h6> <p><?php the_content(); ?></p> <p><?php get_post_meta($post->ID, '_birs_service_price'); ?></p> <br style="clear:both"> </article> <?php endwhile; else : _e('Sorry, No Services Available Currently.'); endif; wp_reset_query(); ?>
Any idea what’s wrong?
July 24, 2013 at 11:59 am #2408Here is what I am using to retrieve and display the price now.
<?php $price = get_post_meta($post->ID, '_birs_service_price', true); ?> <p class="pricing"><span>$</span><?php echo $price; ?></p>
August 7, 2013 at 2:56 am #2598I’m able to display price when adding it to the raw code of a page.
What I’d like to do though is add it as a widget. When I do it shows Title and Content but not the price. Anybody have an idea how to make that happen.
@jon Harmon, thanks for your code, unfortunately it doesn’t work in a widget either.August 8, 2013 at 1:56 pm #2643Found it, forgot to add global $post; to the loop
$loop = new WP_Query( $args ); if ( $loop->have_posts() ) : while( $loop->have_posts() ) : $loop->the_post(); global $post;?>
-
AuthorPosts
The forum ‘BirchPress Scheduler’ is closed to new topics and replies.