Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found the va_get_dashboard_favorites function elsewhere which looks to be the same. The easiest way would be to limit the va_get_dashboard_favorites() WP_Query. e.g.</p> <p><strong>METHOD 1</strong></p> <p><strong>This code was found in wp-content/themes/vantage-new/includes/dashboard.php by the way</strong>:</p> <pre><code>function va_get_dashboard_favorites( $user_id, $self = false ) { $favorites = new WP_Query( array( 'connected_type' =&gt; 'va_favorites', 'connected_items' =&gt; $user_id, 'nopaging' =&gt; true, 'posts_per_page' =&gt; 3, // limiting posts to 3 ) ); return $favorites; } </code></pre> <p>Then to add a view-all link, just add it in iunder the while loop. e.g.</p> <pre><code>&lt;?php $favorites = va_get_dashboard_favorites($dashboard_user-&gt;ID, (bool) $is_own_dashboard ); if ( $favorites-&gt;post_count &gt; 0 ) { while ( $favorites-&gt;have_posts() ) : $favorites-&gt;the_post(); $post_status = $is_own_dashboard ? 'post-status' : ''; ?&gt; &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class( $post_status ); ?&gt;&gt; &lt;?php get_template_part( 'content-listing', get_post_status() ); ?&gt; &lt;/article&gt; &lt;?php endwhile; ?&gt; &lt;br /&gt;&lt;a href="#yourview-all-link-here"&gt;View all&lt;/a&gt; &lt;?php } else { ?&gt; </code></pre> <hr> <p><strong>METHOD 2 (Updated as per OP's update)</strong></p> <p>As per OP's comments, the updated code to just show 3 links</p> <pre><code>&lt;?php $favorites = va_get_dashboard_favorites($dashboard_user-&gt;ID, (bool) $is_own_dashboard ); $counter = 0; $max = 3; if ( $favorites-&gt;post_count &gt; 0 ) { while ( $favorites-&gt;have_posts() and ($counter &lt; $max)) : $favorites-&gt;the_post(); $post_status = $is_own_dashboard ? 'post-status' : ''; ?&gt; &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class( $post_status ); ?&gt;&gt; &lt;?php get_template_part( 'content-listing', get_post_status() ); ?&gt; &lt;/article&gt; &lt;?php $counter++; endwhile; ?&gt; &lt;br /&gt;&lt;a href="#yourview-all-link-here"&gt;View all&lt;/a&gt; &lt;?php } else { ?&gt; </code></pre>
 

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