0

I have problem. I need insert this wp query $cust_loop = new WP_Query( 'author=123' ); But I cant remove the $args from $cust_loop = new WP_Query($args); And i tried everything like$cust_loop = new WP_Query($args, 'author=123');`

I want show posts only by specific user, Thanks :)


if($typecount>0) {
    class con_latest_reviews extends WP_Widget {
        function con_latest_reviews() {
            /* Widget settings. */
            $widget_ops = array( 'classname' => 'Continuum Latest Reviews', 'description' => 'Displays a single review type by most recent or highest rated. Add multiple widgets for each review type.' );
            /* Widget control settings. */
            $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'con_latest_reviews' );
            /* Create the widget. */
            $this->WP_Widget( 'con_latest_reviews', 'Continuum Latest Reviews', $widget_ops, $control_ops );
        }   
        function widget( $args, $instance ) {

            extract( $args );

            /* User-selected settings. */
            $title = apply_filters('widget_title', $instance['title'] );
            $sort = $instance['sort'];
            $reviewtype = $instance['reviewtype'];
            $numreviews = $instance['numreviews'];

            //get review type for More link URL purpose
            $reviewtypeurl = $reviewtype;
            if($reviewtypeurl=="game") $reviewtypeurl="video-game";

            if($sort=="highest-rated") {
                $feedsort="meta_value";
                $metakey="&meta_key=Rating";
            } else {
                $feedsort="date";
                $metakey="";
            } ?>

            <div class="tabdiv reviews <?php echo $reviewtype; ?>">

                <?php

                /* Before widget (defined by themes). */
                echo $before_widget;

                /* Title of widget (before and after defined by themes). */
                if ( $title ) { ?>                  
                    <?php echo str_replace('<h2 class="gentesque">','<h2 class="gentesque">',$before_title); ?>
                        <div class="icon <?php echo $reviewtype; ?>">&nbsp;</div>
                        <?php echo $title; ?>
                    <?php echo $after_title; ?>
                <?php } 

                /* HTML output */
                ?>

                <ul>
                    <?php // setup the query
                    $args='&posts_per_page='.$numreviews.'_reviews&order=DESC&orderby='.$feedsort.$metakey;                             
                    $cust_loop = new WP_Query($args); 
                    if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
                        // if we're sorting by rating and this item does not have a rating, hide it
                        $rating = get_post_meta(get_the_ID(), "Rating", $single = true); 
                        if(($rating && $feedsort=="meta_value") || ($feedsort!="meta_value")) {                                     
                            $ratings = con_setup_rating($rating); //setup the ratings array 
                            ?>
                            <li>                                                                                    

                                <?php con_show_rating($ratings[0], $ratings[1], $ratings[2]); // show the stars or hearts ?>    

                                <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>                                              

                            </li>

                        <?php } ?>
1

1 Answer 1

2

If all you need to do is add that extra parameter, just concatenate it on to the end of $args. (As a side note: I recommend using an array for args instead of the query string method as I find it much more readable.)

<?php
....
$args='&posts_per_page='.$numreviews.'_reviews&order=DESC&orderby='.$feedsort.$metakey.'&author=123';
....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.