par
magot2000 » 30 juin 2021, 15:20
Salut,
J'ai un problème, je tente de trier un affichage d'une query PHP par ordre alphabétique. Pouvez-vous m'aider ?
<?php
/**
* Template Name: Actors
**/
get_header(); ?>
<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<div id="primary" class="content-area <?php echo esc_attr( wpst_get_sidebar_position_class() ); ?> actors-list">
<main id="main" class="site-main <?php echo esc_attr( wpst_get_sidebar_position_class() ); ?>" role="main">
<header class="entry-header">
<?php the_title( '<h1 class="widget-title"><i class="fa fa-star"></i>', '</h1>' ); ?>
</header>
<?php the_content(); ?>
<div class="videos-list">
<?php
// get_query_var to get page id from url
$page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// number of tags to show per-page
$per_page = xbox_get_field_value( 'wpst-options', 'actors-per-page' );
// count total number of terms related to passed taxonomy
$number_of_series = count( get_terms( 'actors' ) );
$offset = ( $page - 1 ) * $per_page;
$term_args = array(
'number' => $per_page,
'offset' => $offset,
);
$terms = get_terms( 'actors', $term_args );
if ( $terms ) {
foreach ( $terms as $term ) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 1,
'show_count' => 1,
'orderby' => 'rand',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'actors',
'field' => 'slug',
'terms' => $term->slug,
),
),
);
$video_from_actor = new WP_Query( $args );
if ( $video_from_actor->have_posts() ) {
$video_from_actor->the_post();
Salut,
J'ai un problème, je tente de trier un affichage d'une query PHP par ordre alphabétique. Pouvez-vous m'aider ?
[PHP]<?php
/**
* Template Name: Actors
**/
get_header(); ?>
<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<div id="primary" class="content-area <?php echo esc_attr( wpst_get_sidebar_position_class() ); ?> actors-list">
<main id="main" class="site-main <?php echo esc_attr( wpst_get_sidebar_position_class() ); ?>" role="main">
<header class="entry-header">
<?php the_title( '<h1 class="widget-title"><i class="fa fa-star"></i>', '</h1>' ); ?>
</header>
<?php the_content(); ?>
<div class="videos-list">
<?php
// get_query_var to get page id from url
$page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// number of tags to show per-page
$per_page = xbox_get_field_value( 'wpst-options', 'actors-per-page' );
// count total number of terms related to passed taxonomy
$number_of_series = count( get_terms( 'actors' ) );
$offset = ( $page - 1 ) * $per_page;
$term_args = array(
'number' => $per_page,
'offset' => $offset,
);
$terms = get_terms( 'actors', $term_args );
if ( $terms ) {
foreach ( $terms as $term ) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 1,
'show_count' => 1,
'orderby' => 'rand',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'actors',
'field' => 'slug',
'terms' => $term->slug,
),
),
);
$video_from_actor = new WP_Query( $args );
if ( $video_from_actor->have_posts() ) {
$video_from_actor->the_post();[/PHP]