Comments (7)
You can still use get_the_post_thumbnail function.
from wedevs-favorite-post.
Yes but I'm a little unsure as to exactly how to include it in your plugin, I'm more of a theme dev than a plugin dev and I don't want to break your nice pluggin. :) Any tips?
from wedevs-favorite-post.
How are you displaying the favorite post actually? With shortcode?
from wedevs-favorite-post.
php directly into the template. I've also very slightly modified your favorite-post.php code (sorry, but i have a very specific need) with the following (see the final printf statement):
/**
* Display favorite posts
*
* @param string $post_type
* @param int $user_id
* @param int $limit
* @param bool $show_remove
*/
function display_favorites( $post_type = 'all', $user_id = false, $limit = 10, $show_remove = true ) {
$posts = $this->get_favorites( $post_type, $user_id, $limit );
echo '<ul class="userBookmarks">';
if ( $posts ) {
$remove_title = __( 'Remove from favorites', 'wfp' );
$remove_link = ' <a href="#" data-id="%s" title="%s" class="wpf-remove-favorite">x</a>';
foreach ($posts as $item) {
$extra = $show_remove ? sprintf( $remove_link, $item->post_id, $remove_title ) : '';
printf( '<li><span class="bookmarkIcon"></span><a href="%s" class="bookmarkLink">%s</a>%s</li>', get_permalink( $item->post_id ), get_the_title( $item->post_id ), $extra );
}
} else {
printf( '<li>%s</li>', __( 'Nothing found', 'wfp' ) );
}
echo '</ul>';
}
You're help is much appreciated.
from wedevs-favorite-post.
Hi there Tareq, any suggestions? I'm not exactly a PHP expert.
from wedevs-favorite-post.
You shouldn't be updating the plugin code. Here's how you can do it:
$favorite_post = WeDevs_Favorite_Posts::init()->get_favorites( 'all', $user_id );
echo '<ul>';
if ( $favorite_post ) {
$remove_title = __( 'Remove from favorite', 'wfp' );
$remove_link = ' <a href="#" data-id="%s" title="%s" class="wpf-remove-favorite">x</a>';
foreach ($favorite_post as $item) {
$extra = $show_remove ? sprintf( $remove_link, $item->post_id, $remove_title ) : '';
?>
<li>
<?php
if ( has_post_thumbnail( $item->ID ) ) {
echo get_the_post_thumbnail( $item->ID, 'thumbnail' );
} else {
//show some blank image
}
?>
<a href="<?php echo get_permalink( $item->ID ); ?>"><?php echo get_the_title( $item->post_id ) ?></a>
<?php echo $extra; ?>
</li>
<?php
}
} else {
printf( '<li>%s</li>', __( 'Nothing found', 'wfp' ) );
}
echo '</ul>';
from wedevs-favorite-post.
Ok thanks for that. I'm not keen usually on changing plugin code directly but I'm really trying to achieve something very specific. Would you consider adding it to a future version?
from wedevs-favorite-post.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wedevs-favorite-post.