文件操作 - related-articles.php
返回文件管理
返回主菜单
删除本文件
文件: /var/www/ltlcompare.com/wp-content/themes/ltl-compare/blocks/related-articles.php
编辑文件内容
<?php use Carbon_Fields\Block; use Carbon_Fields\Field; function ltl_compare_crb_block_related_articles() { Block::make( 'related-articles', __( 'Related articles', DOMAIN ) ) ->add_fields( array( Field::make( 'block_preview', 'preview', __( 'Preview', DOMAIN ) ) ->set_html('<img src="'. TEMPLATE_URL .'/img/block-related-articles.webp" alt="">'), Field::make( 'textarea', 'title', __( 'Title', DOMAIN ) ) ->set_rows( 2 ), Field::make( 'association', 'related_articles', __( 'Related articles', DOMAIN ) ) ->set_types( array( array( 'type' => 'post', 'post_type' => 'blog', ) ) ) ) ) ->set_description( __( 'Related articles', DOMAIN ) ) ->set_keywords( array( __( 'Related articles', DOMAIN ), ) ) ->set_category( 'theme_blocks', __( 'Theme blocks', DOMAIN ) ) ->set_render_callback( function ( $fields, $attributes ) { if ( $fields['title'] || $fields['related_articles'] ) : ?> <div class="custom-block section custom-block-related-articles<?php echo $attributes['className'] ?? null ? ' ' . $attributes['className'] : ''; ?>"> <div class="container slider-wrapp"> <?php if ( $fields['title'] ) : ?> <h2 class="section-title"><?php echo $fields['title']; ?></h2> <?php endif; ?> <?php if ( $fields['related_articles'] ) : $related_articles = wp_list_pluck( $fields['related_articles'], 'id' ); ?> <div class="items-slider swiper"> <div class="swiper-wrapper"> <?php foreach ( $related_articles as $post_id ) : ?> <div class="blog-item items-slide swiper-slide"> <?php if ( has_post_thumbnail( $post_id ) ) : ?> <div class="blog-item-img cover-img"> <img src="<?php echo get_the_post_thumbnail_url( $post_id, 'thumbnail' ); ?>" srcset="<?php echo get_the_post_thumbnail_url( $post_id, 'medium' ); ?> 2x" alt="<?php echo get_post_meta( get_post_thumbnail_id( $post_id ), '_wp_attachment_image_alt', true ); ?>" > </div> <?php endif; ?> <div class="blog-item-title h4"><?php echo get_the_title( $post_id ); ?></div> <?php if ( has_excerpt( $post_id ) ) : ?> <div class="blog-item-desc"><?php echo get_the_excerpt( $post_id ); ?></div> <?php endif; ?> <a href="<?php echo get_the_permalink( $post_id ); ?>" class="blog-item-read-more content-custom-link"><?php _e( 'Read more', DOMAIN ); ?></a> </div> <?php endforeach; ?> </div> </div> <?php endif; ?> <?php include( TEMPLATEPATH . '/inc/slider-nav.php' ); ?> </div> </div> <?php endif; }); } add_action( 'carbon_fields_register_fields', 'ltl_compare_crb_block_related_articles' );
修改文件时间
将文件时间修改为当前时间的前一年
删除文件