gpt4 book ai didi

joomla - 从类别 ID 显示文章的代码?

转载 作者:行者123 更新时间:2023-12-01 12:48:38 24 4
gpt4 key购买 nike

显示类别(由 ID 指定)中的文章的代码是什么?

在 Wordpress 中,这很容易通过执行以下操作:

<?php
query_posts('cat=1');
while (have_posts()) : the_post();
the_title();
endwhile;
?>

我正在为 Joomla 寻找类似的代码。

最佳答案

$db = JFactory::getDbo();
$id = 50;//example

$query = $db->getQuery(true);
$query->select('*');
$query->from('#__content');
$query->where('catid="'.$id.'"');

$db->setQuery((string)$query);
$res = $db->loadObjectList();

foreach($res as $r){
echo '<h3>'.$r->title.'</h3>';
echo $r->introtext;
}

关于joomla - 从类别 ID 显示文章的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14066698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com