• Hi everybody,
    i’m trying to display a list of posts and galleries (instead of only posts). The link is https://www.site.ext/author/nameoftheauthor
    I’m using a theme (Quadrum by orange themes) that i’ve found that is using the “news.php” template.
    I’ve added a filter

    //news.php
    <?php
    	if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    	wp_reset_query();
    
    	if(is_author()){
    
    		add_filter( 'posts_where' , 'getposts_where_filter');
    	}
    ?>
    <?php get_template_part(THEME_LOOP."loop","start"); ?>
    	<?php get_template_part(THEME_SINGLE."page","title"); ?>
    	<?php $counter = 1;?>
    	<?php get_template_part(THEME_SINGLE."page","header"); ?>
    		<div class="blog-style">
    			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    				<?php get_template_part(THEME_LOOP."post"); ?>
    			<?php $counter++; ?>
    			<?php endwhile; else: ?>
    				<?php get_template_part(THEME_LOOP."no","post"); ?>
    			<?php endif; ?>
    			<?php customized_nav_btns($paged, $wp_query->max_num_pages); ?>
    		</div>
    	<?php get_template_part(THEME_SINGLE."page","footer"); ?>
    <?php get_template_part(THEME_LOOP."loop","end"); ?>

    The filter is

    function getposts_where_filter( $where) {
    
    	echo "<!-- PRE CHANGE".$where." -->";
    	if(strpos($where, "AND wp_posts.post_type = 'post'") !== false){
    		$where = str_replace("AND wp_posts.post_type = 'post'", "AND (wp_posts.post_type = 'post' OR wp_posts.post_type = 'gallery')", $where);
    	} else {
    		$where .= " AND wp_posts.post_type = 'gallery'";
    	}
    	echo "<!-- POST CHANGE".$where." -->";
    	return $where;
    }

    And it prints

    <!-- PRE CHANGE AND ( wp_term_relationships.term_taxonomy_id IN (3218) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') -->
    <!-- POST CHANGE  AND ( wp_term_relationships.term_taxonomy_id IN (3218) ) AND (wp_posts.post_type = 'post' OR wp_posts.post_type = 'gallery') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') -->

    But it still displays only posts… where am i wrong?
    Do you need more specifications or files?
    Thank you for the support.
    Leandro

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Author list Posts and Galleries’ is closed to new replies.