2024年03月29日 建站教程
wordpress做接口,php文件中利用mysql语法获取指定分类下的文章,下面web建站小编给大家简单介绍一下具体实现代码!
$title=$_GET['title']; $id='10'; //栏目id=10 $pageSize = 20; $pageNumber=($_GET['pageNumber'] - 1) * $pageSize; //读取所有数据表中的字段 表名 $sql='SELECT ID,post_title,post_date,post_content 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_taxonomy.term_id = "'.$id.'" and taxonomy = "category" AND post_title LIKE "%'.$title.'%" LIMIT 100'; //使用query()方法去链接数据库并执行语句 $result = $demo -> query($sql);
本文链接:http://so.lmcjl.com/news/629/