prowebdesign.ro
Forum Replies Created
-
Forum: Plugins
In reply to: [WP Recipe Maker] Displaying aggregate star rating on post rchiveI totally forgot that you can do the do_shortcode in php templates! Silly me:)). Thank you, solved!
Forum: Plugins
In reply to: [WP Recipe Maker] Displaying aggregate star rating on post rchiveThank you!
The “Access via code” article was just what I needed.If you access the demo link, you’ll see that the post outputs the average rating now: https://www.prowebdesign.ro/clientwp3/index.php/category/dutch-oven-and-camping-recipes/
I have another question though: how do I output the stars? I could write a simple else/if loop, but I suppose this already exists in plugin functions somewhere. I mean the function that outputs stars based on average rating. I just can’t find it. Could you help?
My code is
$recipes = WPRM_Recipe_Manager::get_recipe_ids_from_post();// Access the first recipe, if there is one.
if ( isset( $recipes[0] ) ) {
$recipe_id = $recipes[0];
$recipe = WPRM_Recipe_Manager::get_recipe( $recipe_id );// Output the recipe name.
echo ‘<div class=”alert alert-info”><div>RECIPE NAME: ‘.$recipe->name().'</div>’;
$myrating = $recipe->rating();
echo ‘<div>RECIPE NAME: ‘.$myrating[“average”].'</div></div>’;
}- This reply was modified 5 years, 6 months ago by prowebdesign.ro.
- This reply was modified 5 years, 6 months ago by prowebdesign.ro.
Forum: Themes and Templates
In reply to: [Rowling] Gallery post format bugOups, very sorry, found the docu and figured how it works. Not a bug!
Forum: Plugins
In reply to: Highlight item in list of posts based on current postHi katart17. Thanx for the function – it was just what I was looking for.
Just one small thing to make it better. Your code generates empty classes, if the post is not current. If you don’t need an explicit class on the li tag, you can have class only on current posts like this:<?php $myposts = get_posts('post_type=diseases&numberposts=999&orderby=title&order=ASC'); ?> <?php $postid = get_the_id(); foreach( $myposts as $post) : ?> <li<?php if( $post->ID == $postid ) { echo ' class="current"'; } ?>><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?>