Use Grid widget to display author's posts

Support Forums for LiveMesh Themes & Plugins Forums SiteOrigin Widgets Support Use Grid widget to display author's posts

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29596
    Philippe Lemoine
    Participant

    Hi,

    I have Livemesh SiteOrigin Widgets Pro and I created a custom Archive template, which uses the Grid widget to display the posts in the relevant category or tag, but I would also like to use it for authors.

    This is what archive.php looks like in the child them I created right now:

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package vantage
     * @since vantage 1.0
     * @license GPL 2.0
     */
    
    get_header(); ?>
    
    <section id="primary" class="content-area">
    	
    <header class="page-header"> <h1 id="page-title"><?php if( siteorigin_page_setting( 'page_title' ) ) { echo vantage_get_archive_title(); } ?></h1> <?php if ( is_category() ) { // show an optional category description $category_description = category_description(); if ( ! empty( $category_description ) ) echo apply_filters( 'vantage_category_archive_meta', '
    ' . $category_description . '
    ' ); } elseif ( is_tag() ) { // show an optional tag description $tag_description = tag_description(); if ( ! empty( $tag_description ) ) echo apply_filters( 'vantage_tag_archive_meta', '
    ' . $tag_description . '
    ' ); } else { $description = term_description(); if ( ! empty( $description ) ) echo apply_filters( 'vantage_taxonomy_archive_meta', '
    ' . $description . '
    ' ); } ?> </header><!-- .page-header -->
    <?php if ( is_category() ) { $taxonomy = 'category'; $tax_name = single_cat_title( '', false ); } elseif ( is_tag() ) { $taxonomy = 'post_tag'; $tax_name = single_tag_title( '', false ); }; echo do_shortcode('[siteorigin_widget class="LSOW_Portfolio_Widget"]<input type="hidden" value="{&quot;instance&quot;:{&quot;title&quot;:&quot;&quot;,&quot;heading&quot;:&quot;&quot;,&quot;heading_url&quot;:&quot;&quot;,&quot;header_template&quot;:&quot;block_header_1&quot;,&quot;block_type&quot;:&quot;block_grid_6&quot;,&quot;posts&quot;:&quot;post_type=post&tax_query=' . $taxonomy . ':' . $tax_name . '&date_type=specific&date_query={\&quot;after\&quot;:\&quot;\&quot;,\&quot;before\&quot;:\&quot;\&quot;}&date_query_relative={\&quot;from\&quot;:[],\&quot;to\&quot;:[]}&orderby=date&order=DESC&quot;,&quot;taxonomy_filter&quot;:&quot;' . $taxonomy . '&quot;,&quot;settings&quot;:{&quot;layout_mode&quot;:&quot;fitRows&quot;,&quot;pagination&quot;:&quot;load_more&quot;,&quot;image_linkable&quot;:true,&quot;image_size&quot;:&quot;post-thumbnail&quot;,&quot;enable_lightbox&quot;:true,&quot;post_data&quot;:{&quot;display_title_on_thumbnail&quot;:true,&quot;display_title&quot;:true,&quot;display_summary&quot;:true,&quot;excerpt_length&quot;:25,&quot;post_meta&quot;:{&quot;display_author&quot;:true,&quot;display_post_date&quot;:true,&quot;display_taxonomy&quot;:true,&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;display_comments&quot;:false},&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;display_taxonomy_on_thumbnail&quot;:false,&quot;display_read_more&quot;:false},&quot;per_line&quot;:3,&quot;gutter&quot;:20,&quot;responsive&quot;:{&quot;tablet&quot;:{&quot;gutter&quot;:10,&quot;width&quot;:800,&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;mobile&quot;:{&quot;gutter&quot;:10,&quot;width&quot;:480,&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;filterable&quot;:false,&quot;show_remaining&quot;:false,&quot;post_link_new_window&quot;:false},&quot;_sow_form_id&quot;:&quot;14618065415aab8ba71d52a243364201&quot;,&quot;_sow_form_timestamp&quot;:&quot;1521192023039&quot;},&quot;args&quot;:{&quot;before_widget&quot;:&quot;
    &quot;,&quot;after_widget&quot;:&quot;<\/div>&quot;,&quot;before_title&quot;:&quot;<h3 class=\&quot;widget-title\&quot;>&quot;,&quot;after_title&quot;:&quot;<\/h3>&quot;,&quot;widget_id&quot;:&quot;widget-0-0-0&quot;}}" />[/siteorigin_widget]
    '); ?>
    <!-- #content .site-content --> </section><!-- #primary .content-area --> <?php get_sidebar(); ?> <?php get_footer(); ?>

    This works fine for categories and tags, but for authors it just shows all the posts. How can I do this? I’m guessing that I might be able to use the query parameter I see for the Grid widget in the page builder, but I’m not sure how.

    Best,
    Philippe

    #29602
    Philippe Lemoine
    Participant

    I actually resolved the problem on my own, using the query parameter. In case someone might want to do the same thing, here is the code of my version of archive.php, which uses the Grid widget to display the posts in categories, tags and authors.

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package vantage
     * @since vantage 1.0
     * @license GPL 2.0
     */
    
    get_header(); ?>
    
    <section id="primary" class="content-area">
    	
    <header class="page-header"> <h1 id="page-title"><?php if( siteorigin_page_setting( 'page_title' ) ) { echo vantage_get_archive_title(); } ?></h1> <?php if ( is_category() ) { // show an optional category description $category_description = category_description(); if ( ! empty( $category_description ) ) echo apply_filters( 'vantage_category_archive_meta', '
    ' . $category_description . '
    ' ); } elseif ( is_tag() ) { // show an optional tag description $tag_description = tag_description(); if ( ! empty( $tag_description ) ) echo apply_filters( 'vantage_tag_archive_meta', '
    ' . $tag_description . '
    ' ); } else { $description = term_description(); if ( ! empty( $description ) ) echo apply_filters( 'vantage_taxonomy_archive_meta', '
    ' . $description . '
    ' ); } ?> </header><!-- .page-header -->
    <?php if ( is_category() ) { $taxonomy = 'category'; $tax_name = single_cat_title( '', false ); } elseif ( is_tag() ) { $taxonomy = 'post_tag'; $tax_name = single_tag_title( '', false ); } elseif ( is_author() ) { $author = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); $query = 'author=' . $author->ID; }; echo do_shortcode('[siteorigin_widget class="LSOW_Portfolio_Widget"]<input type="hidden" value="{&quot;instance&quot;:{&quot;title&quot;:&quot;&quot;,&quot;heading&quot;:&quot;&quot;,&quot;heading_url&quot;:&quot;&quot;,&quot;header_template&quot;:&quot;block_header_1&quot;,&quot;block_type&quot;:&quot;block_grid_6&quot;,&quot;posts&quot;:&quot;post_type=post&tax_query=' . $taxonomy . ':' . $tax_name . '&date_type=specific&date_query={\&quot;after\&quot;:\&quot;\&quot;,\&quot;before\&quot;:\&quot;\&quot;}&date_query_relative={\&quot;from\&quot;:{\&quot;value\&quot;:0,\&quot;unit\&quot;:\&quot;days\&quot;},\&quot;to\&quot;:{\&quot;value\&quot;:0,\&quot;unit\&quot;:\&quot;days\&quot;}}&orderby=date&order=DESC&additional=' . $query . '&quot;,&quot;taxonomy_filter&quot;:&quot;' . $taxonomy . '&quot;,&quot;settings&quot;:{&quot;layout_mode&quot;:&quot;fitRows&quot;,&quot;pagination&quot;:&quot;load_more&quot;,&quot;image_linkable&quot;:true,&quot;image_size&quot;:&quot;post-thumbnail&quot;,&quot;enable_lightbox&quot;:true,&quot;post_data&quot;:{&quot;display_title_on_thumbnail&quot;:true,&quot;display_title&quot;:true,&quot;display_summary&quot;:true,&quot;excerpt_length&quot;:25,&quot;post_meta&quot;:{&quot;display_author&quot;:true,&quot;display_post_date&quot;:true,&quot;display_taxonomy&quot;:true,&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;display_comments&quot;:false},&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;display_taxonomy_on_thumbnail&quot;:false,&quot;display_read_more&quot;:false},&quot;per_line&quot;:2,&quot;gutter&quot;:20,&quot;responsive&quot;:{&quot;tablet&quot;:{&quot;gutter&quot;:10,&quot;width&quot;:800,&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;mobile&quot;:{&quot;gutter&quot;:10,&quot;width&quot;:480,&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;so_field_container_state&quot;:&quot;open&quot;},&quot;so_field_container_state&quot;:&quot;open&quot;,&quot;filterable&quot;:false,&quot;show_remaining&quot;:false,&quot;post_link_new_window&quot;:false},&quot;_sow_form_id&quot;:&quot;1947376845aaa4a22a4b57623423779&quot;,&quot;_sow_form_timestamp&quot;:&quot;1521462597114&quot;},&quot;args&quot;:{&quot;before_widget&quot;:&quot;
    &quot;,&quot;after_widget&quot;:&quot;<\/div>&quot;,&quot;before_title&quot;:&quot;<h3 class=\&quot;widget-title\&quot;>&quot;,&quot;after_title&quot;:&quot;<\/h3>&quot;,&quot;widget_id&quot;:&quot;widget-0-0-2&quot;}}" />[/siteorigin_widget]'); ?>
    <!-- #content .site-content --> </section><!-- #primary .content-area --> <?php get_sidebar(); ?> <?php get_footer(); ?>

    I’ll change the status of this thread to “resolved”.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘SiteOrigin Widgets Support’ is closed to new topics and replies.