- <div class=“mb-a left dInline mb-dl”>
-
- <?php
-
- $CID=1;
- global $wpdb;
- $rs = $wpdb->get_results(“select * from wp_posts,wp_term_relationships,wp_term_taxonomy where ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type=’post’ and post_status = ‘publish’ and wp_term_relationships.term_taxonomy_id = $CID and taxonomy = ‘category’ order by ID asc limit 0,3” );
-
- foreach($rs as $cat)
- {?>
- <div class=“mbDiv”>
-
- <img src=“<?php
- //正则匹配内容中的图片
- $post_thumbnail_src = ”;
- ob_start();
- ob_end_clean();
- $output = preg_match_all(‘/<img.+src=[\'”]([^\’“]+)[\'”].*>/i’, $cat->post_content, $matches);
- $post_thumbnail_src = $matches [1] [0];
-
- echo $post_thumbnail_src; ?>” width=”186” height=”132” />
- <p>
- <span><?php echo $cat->post_title;?></span>
- <span> <?php echo $cat->post_excerpt;?> </span>
- </p>
-
- </div>
-
- <?php }?>
-
- </div>
wordpress教程 数据库