Wordpress循环不会返回超过1个帖子

时间:2016-03-17 11:46:48

标签: php wordpress

我创建了一个按类别获取帖子的功能我传递了一个参数来显示每页4个帖子但作为回报我只得到1个帖子

function get_recent_events($atts){
extract(shortcode_atts(array(
    'posts' => 1,
), $atts));

    query_posts(array('category_name' => 'Events', 'orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts));
  if (have_posts()) :
   while (have_posts()) : the_post();
    $output = '<a href="'.get_permalink().'">'.get_the_title().'</a><br />';
   endwhile;
   endif;

    wp_reset_query();
   return $output;
}
add_shortcode("recent_events", "get_recent_events");

并在页面上通过使用带有参数[recent_events posts =“4”]的短代码来调用它应该返回4个帖子但我得到1可以任何人帮助我解决这个问题

1 个答案:

答案 0 :(得分:-1)

试试这个

 public Bitmap rotateImage(String image_path){

    Log.e("Inside rotATE IMAGE", "ROTATE"+image_path);
    Matrix matrix = new Matrix();
    matrix.postRotate(getImageOrientation(image_path));

    bitmap= decodeFile(image_path);
    Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
            bitmap.getHeight(), matrix, true);


    return  rotatedBitmap;
}

public static int getImageOrientation(String imagePath){
    int rotate = 0;
    try {

        File imageFile = new File(imagePath);
        ExifInterface exif = new ExifInterface(
                imageFile.getAbsolutePath());
        int orientation = exif.getAttributeInt(
                ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        Log.e("ori","or" +orientation);

        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_270:
                rotate = 270;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotate = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotate = 90;
                break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return rotate;
}