Архива

0
87

[insert_php]
$cat_code = ”;
global $wpdb;
$wanted = $_GET[“cat_ID”];
$table_prefix = $wpdb->prefix;
$post_list = (array)$wpdb->get_results(”
SELECT ID, post_date, post_content, post_title, {$table_prefix}term_taxonomy.count, {$table_prefix}terms.name as catname
FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy, {$table_prefix}terms
WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id
AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id
AND {$table_prefix}terms.term_id = {$table_prefix}term_taxonomy.term_id
AND {$table_prefix}term_taxonomy.taxonomy = ‘category’
{$cat_code}
AND post_status = ‘publish’
AND post_type != ‘page’
AND {$table_prefix}term_relationships.term_taxonomy_id={$wanted}
ORDER BY catname, post_date DESC
“);
//print_r($post_list);
//echo count($post_list);
$catname = $post_list[0]->catname;
$count = $post_list[0]->count;
//echo $a;
echo “

“;
$allPosts = array();
foreach ($post_list as $p) {
$id = $p->ID;
//$catname = $p->catname;
$link = get_permalink($p->ID);
$title = $p->post_title;
//$count = $post_list[0]->count;
$date = date(“j/m/Y”, strtotime($p->post_date));
$content = wp_trim_words( $p->post_content );
//$content = substr($content, 0, 300);
$content .= “…”;
$printIt = “

{$title}
{$date} | {$content}


“;
//echo $printIt;
array_push($allPosts, $printIt);
}

//print_r($allPosts);
$postsPerPage = 10;
$paged = array_chunk($allPosts, $postsPerPage);
//print_r($paged);
$noPages = count($paged);

if (isset($_GET[“currentPage”])){
for ($i=0;$i1){ //no need to create pagination if only 1 sheet is present
//echo “{$count} статии пронајдени”;
echo “

“;
}else
//echo “{$count} статија пронајдена”;
echo “

“;
[/insert_php]