2021-02-18 14:09:56 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Home Template
|
|
|
|
*
|
|
|
|
* This template is loaded when on the home/blog page.
|
|
|
|
* Es mostren a la home els posts o pages que tinguin marcat el custom field Inici a 1 i s'ordenen pel valor del custom field Ordre, i sino per data publicació.
|
|
|
|
* @package Hangar
|
|
|
|
* @subpackage Template
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php get_header(); ?>
|
2022-02-01 08:37:21 +01:00
|
|
|
|
|
|
|
<?php if( is_home( )) : ?>
|
|
|
|
<?php // show big widget area if homepage and if active ?>
|
|
|
|
<aside class="hero">
|
|
|
|
<?php if ( ! dynamic_sidebar( 'secondary-widget-area' ) ) : ?>
|
|
|
|
<?php endif; // end secondary widget area ?>
|
|
|
|
</aside>
|
|
|
|
<?php endif; //end if is_home ?>
|
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
<div id="main" class="maingran">
|
2022-07-08 16:30:53 +02:00
|
|
|
<div id="content" class="indexall">
|
2021-02-18 14:09:56 +01:00
|
|
|
|
|
|
|
<?php
|
|
|
|
global $wpdb; //seleccionem els posts pels camps creats Inici = 1 i ordenem els registres pel valor del camp Ordre (meta_key / meta_value)
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
$total = "
|
|
|
|
SELECT *
|
|
|
|
FROM $wpdb->posts wposts
|
|
|
|
INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id
|
|
|
|
INNER JOIN $wpdb->postmeta m2 ON wposts.ID = m2.post_id
|
|
|
|
WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page')
|
|
|
|
AND m1.meta_key = 'Inici'
|
|
|
|
AND m1.meta_value = '1'
|
|
|
|
AND m2.meta_key = 'Ordre_inici'
|
2022-07-08 16:30:53 +02:00
|
|
|
AND wposts.post_status = 'publish'
|
2021-02-18 14:09:56 +01:00
|
|
|
GROUP BY ID
|
2022-07-08 16:30:53 +02:00
|
|
|
ORDER BY CAST( m2.meta_value AS SIGNED ) ASC
|
2021-02-18 14:09:56 +01:00
|
|
|
";
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
$totalposts = $wpdb->get_results($total, OBJECT);
|
|
|
|
$ppp = intval(get_query_var('posts_per_page')); //sçon 11 per la resta de pàgines índex però a la home en volem 12
|
|
|
|
$ppp = intval(16);
|
|
|
|
$wp_query->found_posts = count($totalposts);
|
2022-07-08 16:30:53 +02:00
|
|
|
$wp_query->max_num_pages = ceil($wp_query->found_posts / $ppp);
|
|
|
|
$on_page = intval(get_query_var('paged'));
|
|
|
|
if($on_page == 0){ $on_page = 1; }
|
2021-02-18 14:09:56 +01:00
|
|
|
$offset = ($on_page-1) * $ppp;
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
$wp_query->request = "SELECT *
|
|
|
|
FROM $wpdb->posts wposts
|
|
|
|
INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id
|
|
|
|
INNER JOIN $wpdb->postmeta m2 ON wposts.ID = m2.post_id
|
|
|
|
WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page')
|
|
|
|
AND m1.meta_key = 'Inici'
|
|
|
|
AND m1.meta_value = '1'
|
|
|
|
AND m2.meta_key = 'Ordre_inici'
|
2022-07-08 16:30:53 +02:00
|
|
|
AND wposts.post_status = 'publish'
|
2021-02-18 14:09:56 +01:00
|
|
|
GROUP BY ID
|
2022-07-08 16:30:53 +02:00
|
|
|
ORDER BY CAST( m2.meta_value AS SIGNED ) ASC
|
2021-02-18 14:09:56 +01:00
|
|
|
LIMIT $ppp OFFSET $offset";
|
2022-07-08 16:30:53 +02:00
|
|
|
|
|
|
|
$pageposts = $wpdb->get_results($wp_query->request, OBJECT);
|
|
|
|
|
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
?>
|
|
|
|
<?php if ($pageposts): //amb els resultats trobats per la query distingim les categories de les pàgines pq s'han de pintar diferent
|
2022-07-08 16:30:53 +02:00
|
|
|
global $post;
|
2021-02-18 14:09:56 +01:00
|
|
|
echo '<ul>';
|
2022-07-08 16:30:53 +02:00
|
|
|
foreach ($pageposts as $post):
|
|
|
|
setup_postdata($post);
|
|
|
|
$category = get_the_category();
|
|
|
|
if ($category) :
|
2021-02-18 14:09:56 +01:00
|
|
|
$tipus = 'catt' ;
|
|
|
|
else:
|
|
|
|
if (is_page_child($post, 2)) :
|
2022-07-08 16:30:53 +02:00
|
|
|
$tipus = 'art'; //artistes
|
2022-09-27 10:18:26 +02:00
|
|
|
elseif (is_page_child($post, 58856)) :
|
|
|
|
$tipus = 'art'; //artistes
|
|
|
|
elseif (is_page_child($post, 46565)) :
|
|
|
|
$tipus = 'art'; //artistes
|
|
|
|
elseif (is_page_child($post, 46572)) :
|
|
|
|
$tipus = 'art'; //artistes
|
2021-02-18 14:09:56 +01:00
|
|
|
elseif (is_page_child($post, 136)) :
|
2022-07-08 16:30:53 +02:00
|
|
|
$tipus = 'desc'; //descàrregues
|
2021-02-18 14:09:56 +01:00
|
|
|
elseif (is_page_child($post, 74)) :
|
2022-09-27 10:18:26 +02:00
|
|
|
$tipus = 'equip'; //equip
|
|
|
|
elseif (is_page_child($post, 40378)) :
|
|
|
|
$tipus = 'equip'; //equip
|
2021-02-18 14:09:56 +01:00
|
|
|
else :
|
|
|
|
$tipus = 'pag';
|
|
|
|
endif;
|
|
|
|
endif;
|
2022-07-08 16:30:53 +02:00
|
|
|
|
|
|
|
include(TEMPLATEPATH . "/caixes.php");
|
2021-02-18 14:09:56 +01:00
|
|
|
|
|
|
|
endforeach; ?>
|
|
|
|
</ul>
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
|
|
|
|
<?php wp_pagenavi(); ?>
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
<?php else : ?>
|
|
|
|
<h2 class="center"><?php _e( 'Not found.', 'hangar' ); ?></h2>
|
|
|
|
<p class="center"><?php _e( "Sorry, but you are looking for something that isn't here.", 'hangar' ); ?></p>
|
|
|
|
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
|
|
|
|
<?php endif;
|
|
|
|
wp_reset_postdata();
|
|
|
|
?>
|
|
|
|
|
|
|
|
</div> <!-- content -->
|
|
|
|
</div><!-- fi main -->
|
2022-07-08 16:30:53 +02:00
|
|
|
|
2021-02-18 14:09:56 +01:00
|
|
|
<?php get_footer(); ?>
|