display voting widget in a post list
-
I’m trying to show the widget in a repeater list. My list is a template part of the plugin ajax load more (https://wordpress.org/plugins/ajax-load-more/). At the first time my code was like that:
<div style="min-width:100%;margin-top:3px;display:inline;"> <div class="f2"> <span> <a href="<?php the_permalink(); ?> title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span> <?php echo do_shortcode('[voter]'); ?> </span> </div> </div>
And since it didn’t work out I changed the shortcode like that
/******************************* shotcode :: [voter] ****************************/ function aheadzen_voter_plugin_shortcode($atts) { $atts['shortcode']=1; global $post,$wpdb; if ($atts["ptype"] != "") { $post_type = ''; $component_name = ''; $component_name = "blog"; $post_type = $atts["ptype"]; $item_id = 0; $secondary_item_id = $atts["pid"]; $params = array( 'component' => $component_name, 'type' => $post_type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id ); } else { $post_type = $post->post_type; $component_name = ''; if($post_type=='page'){ $component_name = "blog"; }elseif($post_type=='post'){ $component_name = "blog"; }elseif($post_type=='product'){ $component_name = "woocommerce"; }elseif($post_type && !in_array($post_type,array('page','post','product'))){ $component_name = "custompost"; } $item_id = 0; $secondary_item_id = $post->ID; $params = array( 'component' => $component_name, 'type' => $post_type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id ); } return $voting_links = VoterPluginClass::aheadzen_get_voting_link($params); }
and in repeater:
<div style="min-width:100%;margin-top:3px;display:inline;"> <div class="f2"> <span> <a href="<?php the_permalink(); ?> title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span> <?php echo do_shortcode('[voter ptype="post", pid="the_id();"]'); ?> </span> </div> </div>
But still there is nothing to show.
Note: as you may have noticed I’m trying to give the user the ability to vote without opening the post… .
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘display voting widget in a post list’ is closed to new replies.