Enable Post Voting for excerpts

Post Voting plugin only adds voting if a full content of a post is being displayed but not to excerpts. For example, if a blog page shows the full content of posts on post list, voting can be added there. It cannot be added if it shows excerpts.

Plugins seem to be hooking to "the_content" WP filter only. If the excerpt is served via "the_excerpt()" WP function (as expected), voting buttons are not injected.

  • Dimitris

    Hello there rc_snowboarder

    I can see that this is already escalated to our devs and we're waiting for some feedback from them.
    Meanwhile, I was able to find a workaround. You can select the "full post" option in Upfront Posts element, then limit its length programmatically. For that, you should create a little MU plugin file like, /wp-content/mu-plugins/limit-content-length.php (simply create the /mu-plugins/ folder, if it doesn't exist already) and insert in there the exact following snippet:

    <?php
    add_action('wp','enable_content_filter');
    
    function enable_content_filter() {
      // check where to limit content length
      if ( is_home() || is_front_page() ) {
        add_filter('the_content', 'plugin_myContentFilter');
      }
    }
    
    function plugin_myContentFilter($content) {
      // Take the existing content and return a subset of it (100 characters)
      return substr($content, 0, 100);
    }

    Hope that's some help! :slight_smile:

    Take care,
    Dimitris

  • Dimitris

    Hello there rc_snowboarder,

    hope you're doing good today! :slight_smile:

    I was able to reproduce the same issue in a local site of mine. It seems that Upfront is fetching post vote for first post of loop only, you will notice that if you switch into another default theme like TwentySeventeen, all posts don't have any vote, only first post.

    I've already created a report for our Second Level Support team, just in case there's anything that we could do for that, as there's no official integration between Post Voting and Upfront.

    Me or another colleague of mine will keep you posted here, as soon as we've got some valuable insights. Your patience on this is highly appreciated, as the response times of our devs are quite longer than ours, in support staff.

    Warm regards,
    Dimitris

  • Ivan

    Hi rc_snowboarder !

    You can try to change the get_posts_markup function into {wordpress_folder}/wp-content/themes/upfront/elements/upfront-posts/lib/class_upfront_posts_posts_view.php file via FTP (approximately 15th line) from this option

    public static function get_posts_markup ($data) {
    	$posts = Upfront_Posts_Model::get_posts($data);
    	$posts_markup = array();
    
    	$view = new Upfront_Posts_PostView($data);
    
    	foreach($posts as $idx => $post) {
    		$posts_markup[$idx] = $view->get_markup($post);
    	}
    
    	return $posts_markup;
    }

    to this one

    public static function get_posts_markup ($data) {
    	$posts = Upfront_Posts_Model::get_posts($data);
    	$posts_markup = array();
    
    	$view = new Upfront_Posts_PostView($data);
    
    	foreach($posts as $idx => $_post) {
    		global $post;
    		$post = get_post( $_post->ID, OBJECT );
    		setup_postdata( $post );
    		$posts_markup[$idx] = $view->get_markup($_post);
    		wp_reset_postdata();
    	}
    
    	return $posts_markup;
    }

    Also, I'll provide this change for implementing to the new versions of the plugin.

    Best,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.