Buenas tengo un codigo que recojo empleos de un custom post en wordpress, los voy mostrando en un foreach. Me gustaria saber alguna forma para hacer paginacion de 6 elementos por pagina.
<?php
/* Template Name: Lista Jobs */
/**
* Blog list template
*
* @package vogue
* @since 1.0.0
*/
//Funciones
function check_in_range($fecha_inicio, $fecha_fin, $fecha){
$fecha_inicio = strtotime($fecha_inicio);
$fecha_fin = strtotime($fecha_fin);
$fecha = strtotime($fecha);
if(($fecha >= $fecha_inicio) && ($fecha <= $fecha_fin)) {
return true;
} else {
return false;
}
}
// File Security Check
if ( ! defined( 'ABSPATH' ) ) { exit; }
$config = Presscore_Config::get_instance();
$config->set( 'template', 'page' );
//Libreria para poder usar wordpress.
include('../../../wp-load.php');
//Argumentos para hacer la Query.
$args = array(
'post_type' => 'ofertasempleo',
'post_status '=> 'publish',
'posts_per_page' => -1
);
//Obtenemos las clinicas del sistema.
$jobsAUX = new WP_Query($args);
//var_dump($jobsAUX);
//Si tenemos clinicas disponibles.
if ( $jobsAUX->have_posts() ) {
//Creamos pila de trabajos.
$jobs = array();
//Entramos en bucle para obtener los jobsAUX.
while ( $jobsAUX->have_posts() ) : $jobsAUX->the_post();
$location = array(
"titulo" => get_the_title(),
"activo" => get_field("activo"),
"imagen" => get_the_post_thumbnail_url(),
"url" => get_the_permalink(),
"inicio" => get_field("fecha_inicio"),
"fin" => get_field("fecha_fin")
);
//Almacenamos las posiciones.
array_push($jobs, $location);
endwhile;
//Reseteamos el postdata.
wp_reset_postdata();
}
get_header();
if ( presscore_is_content_visible() ): ?>
<!-- Content -->
<div id="content" class="content content-empleo" role="main">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post(); // main loop
do_action( 'presscore_before_loop' );
the_content();
//Cotenido // SACAR STYLE DE AQUI
?>
<div class="jobs-container">
<?php
foreach ($jobs as $job) {
$titulo = $job['titulo'];
$img = $job['imagen'];
$url = $job['url'];
$fechaInicio = $job['inicio'];
$fechaFin = $job['fin'];
$fechaActual = date('Y-m-d');
$caducado = $job['activo'];
if($fechaInicio != null && $fechaFin != null){
$activo = check_in_range($fechaInicio,$fechaFin,$fechaActual);
}else{
$activo = $caducado;
}
?>
<div class="cajaEmpleo">
<a class="empleoUrl" href="<?php echo $url;?>">
<div class="contenidoEmpleo">
<div class="blackground">
<img class="imgEmpleo" src="<?php echo $img;?>" alt="GMEDIA"/>
</div>
<div class="tituloEmpleo" >
<h3><?php echo $titulo; ?></h3>
</div>
<?php if($activo){?>
<div class="estadoEmpleo" style="background: #00a000;">Activa</div>
<?php }else{ ?>
<div class="estadoEmpleo" style="background: #be3631;">Caducada</div>
<?php }?>
</div>
</a>
</div>
<?php
}
?>
</div>
<?php
//Fin Contenido
do_action( 'presscore_after_loop' );
endwhile; endif; // main loop
?>
</div><!-- #content -->
<?php do_action('presscore_after_content');
endif; // if content visible
get_footer(); ?>