Hi there!
You can only use functionalities that are already built into the plugin with the Custom HTML Markup feature.
To use features that aren’t built-in into WPP you’ll have to use either the wpp_post filter or the wpp_custom_html filter.
Hi Hector,
Thanks for the reply. Really appreciate it. Do you have an example?
Or perhaps i can hire you to write it up if you’re currently available.
Try this:
function my_custom_single_popular_post( $post_html, $p, $instance ){
$output = '<li><a href="' . get_the_permalink( $p->id ) . '">' . get_post_meta( $p->id, 'YOUR_CUSTOM_FIELD_KEY_GOES_HERE', true ) . '</a></li>';
return $output;
}
add_filter( 'wpp_post', 'my_custom_single_popular_post', 10, 3 );
Excellent, Hector! 🙂
I’m currently trying to use this code to output 5 custom field values (in header.php) that are linking to the post.
But what if I’m already using WPP on a sidebar widget? I noticed this effects that sidebar widget and also gives me missing arguments warnings.
http://frightfeed.com/blair-witch-sequel-set-for-september
Thank you for the assistance. Highly appreciate it!
Let me revise my previous post.
What is the correct PHP code to place in the header.php and sidebar.php in order to make these two functions work?
function my_trending_post( $post_html, $p, $instance ){
$output = '<li><a href="' . get_the_permalink( $p->id ) . '">' . get_post_meta( $p->id, 'Trending', true ) . '</a></li>';
return $output;
}
add_filter( 'wpp_post', 'my_trending_post', 10, 3 );
function my_custom_sidebar( $post_html, $p, $instance ){
$output = '<div class="holder"><a href="' . get_the_permalink( $p->id ) . '">' . $p->thumb_img . '</a><p><a href="' . get_the_permalink( $p->id ) . '">' . $p->title . '</a></p><span>' . $p->category . '</span></div>';
return $output;
}
add_filter( 'wpp_post', 'my_custom_sidebar', 10, 3 );
The code below works but only if it’s one WPP on the site…
if ( function_exists('wpp_get_mostpopular') )
wpp_get_mostpopular('order_by=views&limit=5&range=monthly');
Hi there!
Had a busy weekend and couldn’t get back to you until now. Let’s get down to business!
But what if I’m already using WPP on a sidebar widget? I noticed this effects that sidebar widget…
Indeed, the code affects all instances of the plugin (widget, [wpp] shortcode and the wpp_get_mostpopular() template tag). It is possible to give each one a different template with the current version of the plugin, but you’ll have to patch a bug that hasn’t been fixed yet and then you can do this.
About the “missing arguments” warning, I’ll take a look into it as soon as I can. For the time being, please set WP_DEBUG to false to hide the message.
Hi Hector,
I patched up the bug and got it to work just fine. I had to empty out the cache in order for this to work but that wasn’t an issue as this is a new site/blog. I imagine this might be an issue if you are running an established site and needed to add custom fields to WPP.
The “missing arguments” warning, an error on my side. I used the wrong code in header.php
Thank you for all the support. you’re awesome, Hector!