• Hi, I’ currrently using this plugin and I’m showing it into the front page. Since I’m using it to display the most viewed products of a catalog and I already had a custom display for the product wich is thumbnail, taxonomy, title and a custom field with the price, I need to get the taxonomy and the custom file value from the top products.

    I’m really lost with this issue, please HELP !!!

    https://www.ads-software.com/plugins/top-10/

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Ajay

    (@ajay)

    The easiest way would have to be a manual install taking advantage of the API.

    https://gist.github.com/ajaydsouza/c8defd4b46e53240e376

    You will need to fetch the top posts using the plugin function, create a WP_Query request and then output them in the loop. You’ll have to add the necessary functions to get the thumbnail, taxonomy, etc.

    Thread Starter alejas91

    (@alejas91)

    Thanks for the quick reply,

    I installed manually the plugin and used the fetch function that you suggested.

    The issue that I’m having now is that anything is showing as the top posts. I printed step by step the function and the problem seems to be in the loop area.

    I’m using this, but I’m not getting anything on the page.

    <?php
    /*
    * This example fetches the popular posts tracked by Top 10.
    *
    */
    
    				if ( function_exists( 'get_tptn_pop_posts' ) ) {
    					$settings = array(
    						'daily' => TRUE,
    						'daily_range' => 30,
    						'limit' => 20,
    						'strict_limit' => FALSE,
    					);
    					$topposts = get_tptn_pop_posts( $settings ); // Array of posts
    
    					$topposts = wp_list_pluck( (array) $topposts, 'postnumber' );
    					//print_r($topposts);
    					$args = array(
    						'post__in' => $topposts,
    						'orderby' => 'post__in',
    						'posts_per_page' => 5,
    						'ignore_sticky_posts' => 1
    					);
    					//print_r($args);
    					$my_query = new WP_Query( $args );
    					if ( $my_query->have_posts() ) {
    
    						while ( $my_query->have_posts() ) {
    							$my_query->the_post();
    							echo '<a href="' . get_permalink( get_the_ID() ) . '">';
    							the_title();
    							echo '</a>';
    							wp_reset_postdata();
    						}
    
    					} else {
    					}
    					wp_reset_query();
    				} ?>
    Plugin Author Ajay

    (@ajay)

    I noticed that you’ve used print_r at various stages. Are you fine until the loop?

    What do you get if you print after $my_query = new WP_Query( $args );

    Thread Starter alejas91

    (@alejas91)

    That’s my problem, when I get there I get emty. Everything else before is fine. I think the $my_query = new WP_Query( $args );
    is a native wordpress query so, I really dont know whats wrong…

    Plugin Author Ajay

    (@ajay)

    Does this give a result print_r($topposts);

    I suggest installing Query Monitor which gives you a list of queries so you can figure out what the WP_Query is spitting out.

    Thread Starter alejas91

    (@alejas91)

    Yes It does
    print_r($topposts) = Array ( [0] => 56 [1] => 54 [2] => 52 [3] => 45 [4] => 34 [5] => 106 [6] => 50 )

    and

    print_r($args) = Array ( [post__in] => Array ( [0] => 56 [1] => 54 [2] => 52 [3] => 45 [4] => 34 [5] => 106 [6] => 50 ) [orderby] => post__in [posts_per_page] => 5 [ignore_sticky_posts] => 1 )

    but print_r($wp_query) shows anything, it is empty and i can’t figure out why ??

    Plugin Author Ajay

    (@ajay)

    This is indeed extremely strange.

    I assume a var_dump( $my_query ) reveals nothing?

    Can you install query monitor. It allows you to see what queries are being run. Should help figure out if the WP_Query is working or throwing up an error.

    Might also be worthwhile just trying a different piece of code from https://www.smashingmagazine.com/2013/01/using-wp_query-wordpress/ to see if the arguments are an issue.

    BTW. I tested your code on my test install and it threw up results perfectly.

    Thread Starter alejas91

    (@alejas91)

    Still no answer… I don’t know what else to do… I really don’t know what am I doing wrong…

    Plugin Author Ajay

    (@ajay)

    Any chance I can get access?

    Did you try Query Monitor plugin?

    Also, worth trying with another theme as well

    Thread Starter alejas91

    (@alejas91)

    Yes you can. this is the link to the page,

    the $wp_query is currently printed at the end of the front page. What else do you need to see?

    Thread Starter alejas91

    (@alejas91)

    Hello, can you help me with this?

    Plugin Author Ajay

    (@ajay)

    Can I get access to a staging site with Query Monitor plugin installed for me to see?

    Thread Starter alejas91

    (@alejas91)

    Sure, how can I give you acces on private?

    Plugin Author Ajay

    (@ajay)

    Drop me an email via https://webberzone.com/contact/ and point me to this thread.

    Thread Starter alejas91

    (@alejas91)

    Okay, I did! ??

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Show taxonomy and custom field’ is closed to new replies.