Note that there are some explanatory texts on larger screens.

plurals
  1. POneed to create a related taxonomy stores
    primarykey
    data
    text
    <p>I have a coupon site, which basically has many vendors in it. I want to create a related stores widget kind of a thing which would display 5-6 stores on the side bar. and i want to them to relate to the current vendor page. till now i have managed to display 5-6 stores links randomly, but i am not able to display the related stores. I am using clipper theme in wordpress, and i have kept all my stores in Coupons-Stores and not Post-categories.</p> <pre><code>&lt;?php $stores = get_terms('stores'); // Note: this returns NULL non-empty cats. It is not normal, could be because of the widget. // Get all non-empty stores $nonempty_stores = array(); foreach( $stores as $store ) if ( !empty( $store ) ) $nonempty_stores[] = $store; $stores_count = count($nonempty_stores); global $random_seed; // Set initial seed value $random_seed = $last_update; if (DISPLAY_SAME_STORES_LIST_FOR_ALL_STORE_PAGES == false) $random_seed = $random_seed + $store_catid; function mtech_rand($min, $max) { global $random_seed; $random_seed = ((1103515245*$random_seed)+12345)%(1&lt;&lt;31); return (($random_seed%($max-$min+1))+$min); } echo "&lt;div class=\"hdsboxbg\"&gt;&amp;nbsp;"; $cntr = 0; $displayed_cntr = 0; while (($cntr &lt; $stores_count) &amp;&amp; ($displayed_cntr &lt; NUM_OF_RANDOM_STORES_TO_DISPLAY)) { $rand_store_idx = mtech_rand($cntr, $stores_count-1); $rand_store = $nonempty_stores[$rand_store_idx]; if (($store_catid == 0) || ($rand_store-&gt;cat_ID != $store_catid)) // Random Stores Widget should not display a link to the current store page { $a_text = $rand_store-&gt;name . ' Coupons'; //$a_text = $rand_store-&gt;name; echo "&lt;div class=\"hdsmod\"&gt;&lt;a href=\"". get_category_link($rand_store-&gt;cat_ID) . "\"&gt; $a_text &lt;/a&gt;&lt;/div&gt;"; $displayed_cntr++; } $nonempty_stores[$rand_store_idx] = $nonempty_stores[$cntr]; $nonempty_stores[$cntr] = $rand_store; $cntr++; } echo "&lt;/div&gt;"; ?&gt; </code></pre> <p>Any other methods are welcome. i have tried to display all the stores like this, </p> <pre><code>$terms = get_terms('stores'); echo '&lt;ul&gt;'; foreach ($terms as $term) { //Always check if it's an error before continuing. get_term_link() can be finicky sometimes $term_link = get_term_link( $term, 'stores' ); if( is_wp_error( $term_link ) ) continue; //We successfully got a link. Print it out. echo '&lt;li&gt;&lt;a href="' . $term_link . '"&gt;' . $term-&gt;name . '&lt;/a&gt;&lt;/li&gt;'; } echo '&lt;/ul&gt;'; </code></pre> <p>it displays but i am not able to display the related stores, i am struggling to figure out on which grounds should i proceed. Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload