• Resolved sajed.kerec

    (@sajedkerec)


    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… .

    https://wordpress.org/plugins/voter-plugin/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author aheadzen

    (@aheadzen)

    <?php echo do_shortcode('[voter ptype="post", pid="the_id();"]'); ?> </span>

    can you post output for above, i don’t think that’s correct code. you should be calling get_the_ID() properly.

    Thread Starter sajed.kerec

    (@sajedkerec)

    Thanks fo the reply.
    The output is nothing. I think the shortcode only works if the user opens the page or post and not in external list… . Do you have any ideas?

    Plugin Author aheadzen

    (@aheadzen)

    yes the voting plugin working on item id mean any post, page… ids..
    by default it get id from $post->ID

    Mean try to get id from post data and if there is no post data, it will not work for you.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘display voting widget in a post list’ is closed to new replies.