Toutes mes réponses sur les forums
2 sujets de 1 à 2 (sur un total de 2)
-
AuteurMessages
-
J’ai trouvé ce qui me conviendrai parfaitement.
Le hic c’est que c’est sur un autre thème.
Je débute sur WordPress et le PHP, mais y-a-t il un moyen de changer les variables pour que le bout de code suivant puisse marcher sur le thème OceanWP ? Je parle de la partie PHP, pour le CSS je m’y retrouve.
Merci d’avance pour votre aide
<section class="slider-wrapper"> <div class="apmag-container"> <?php $accesspress_mag_slider_layout = of_get_option( 'slider_layout' ); if( $accesspress_mag_slider_layout == 'slider_highlight' ) { do_action('sportsmag_grid'); } else { if( wp_is_mobile() ) { do_action( 'accesspress_mag_slider_mobile' ); } else { do_action( 'sportsmag_grid' ); } } ?> </div> </section><!-- .slider-wrapper --> <div class="apmag-container"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <section class="popular-news wow fadeInUp clearfix" data-wow-delay="0.5s"> <?php $sportsmag_popular_block_show_option = of_get_option( 'popular_section_option', '1' ); if ( $sportsmag_popular_block_show_option == '1' ) { $sportsmag_popular_block_name = of_get_option( 'popular_block_name', __( 'Popular text', 'sportsmag' ) ); ?> <div class="popular-block-wrapper"> <h3 class="block-title"><span><?php echo esc_attr( $sportsmag_popular_block_name ); ?></span></h3> <div class="block-post-wrapper clearfix"> <?php $sportsmag_popular_args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'order' => 'DESC' ); $sportsmag_popular_query = new WP_Query($sportsmag_popular_args); $sportsmag_total_posts_block1 = $sportsmag_popular_query->post_count; $sportsmag_pop_count = 0; if ( $sportsmag_popular_query->have_posts() ) { while ( $sportsmag_popular_query->have_posts() ) { $sportsmag_popular_query->the_post(); $sportsmag_pop_count++; $sportsmag_pop_image_id = get_post_thumbnail_id(); $sportsmag_pop_image_alt = get_post_meta( $sportsmag_pop_image_id, '_wp_attachment_image_alt', true ); if ( $sportsmag_pop_count == 1 ) { echo '<div class="toppost-wrapper">'; } if ( $sportsmag_pop_count > 2 && $sportsmag_pop_count == 3 ) { echo '<div class="bottompost-wrapper">'; } if( $sportsmag_pop_count <= 2 ) { $single_post_class = 'top-post non-zoomin'; $sportsmag_image_size = wp_get_attachment_image_src( $sportsmag_pop_image_id, 'accesspress-mag-block-big-thumb', true ); } else { $single_post_class = ''; $sportsmag_image_size = wp_get_attachment_image_src( $sportsmag_pop_image_id, 'accesspress-mag-block-small-thumb', true ); } ?> <div class="single_post clearfix <?php echo esc_attr($single_post_class); ?>"> <div class="post-image"> <a href="<?php the_permalink(); ?>"> <?php if( has_post_thumbnail() ) { ?> <img src="<?php echo esc_url( $sportsmag_image_size[0] );?>" alt="<?php echo esc_attr( $sportsmag_pop_image_alt ); ?>" /> <?php } else { ?> <img src="<?php echo esc_url( get_template_directory_uri(). '/images/no-image-small.jpg' ); ?>" alt="<?php esc_html_e( 'No image', 'sportsmag' ); ?>" /> <?php } ?> </a> <?php if ( $sportsmag_pop_count <= 2 ) { ?> <a class="big-image-overlay" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><i class="fa fa-external-link"></i></a><?php } ?> </div><!-- .post-image --> <div class="post-desc-wrapper"> <h3 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <div class="block-poston"><?php if( $sportsmag_pop_count <=2 ){ ?> <span class="post-author"><?php the_author_posts_link(); ?></span> <?php } ?><?php do_action( 'accesspress_mag_home_posted_on' ); ?></div> </div><!-- .post-desc-wrapper --> <?php if ( $sportsmag_pop_count <= 2 ) { ?><div class="post-content"><?php echo '<p>' . esc_html(accesspress_mag_word_count( get_the_content(), 25 )) . '</p>'; ?></div><?php } ?> </div><!-- .single_post --> <?php if ( $sportsmag_pop_count % 2 == 0 ) { echo '<div class="clearfix"></div>'; } if ( $sportsmag_pop_count > 2 && $sportsmag_pop_count == $sportsmag_total_posts_block1 ) { echo '</div>'; } if ( $sportsmag_pop_count == 2 ) { echo '</div>'; } }//endwhile }//endif ?> </div><!-- .block-post-wrapper --> </div><!-- .popular-block-wrapper --> <?php } wp_reset_query(); ?> </section><!-- .popular-news -->
PostsOK, je vais regarder ça.
Merci en tout cas pour l’aide ! 🙂
-
AuteurMessages
2 sujets de 1 à 2 (sur un total de 2)