FanaByte در پست رندوم نمایش دادن نمونه کارها در سایت یک ارسال را به عنوان پاسخ، انتخاب کرد
16 اردیبهشت، 2025
با توجه به توضیحاتی که شما فرمودید ما اصلاحات و انجام دادیم و سایت با همون حالتی که خواستید در حال نمایش میباشد.
شما از قالب Fluxus استفاده میکنید که برای این کار با توجه به اینکه نمونه کارهای شما به حالت Grid در حال نمایش است باید به بخش ویرایشگر قالب رفته و template-portfolio-grid.php را ویرایش کنید و کدهای آن را ویرایش کنید.
کدهای اصلی قالب مربوط به template-portfolio-grid.php
<?php
/*
Template Name: Grid Portfolio
*/
$columns = false;
$rows = false;
$image_sizes = array();
if ( have_posts() ) :
if ( is_page() ) {
$grid_portfolio = new GridPortfolio( get_the_id() );
// Sets: $orientation, $aspect_ratio, $grid_size, $image_sizes, $image_cropping, $columns, $rows
extract( $grid_portfolio->get_options() );
} else {
extract( GridPortfolio::grid_options() );
/**
* We are on a Project Type page,
* thus we need to check if there is any overriden options.
*
* Sets: $orientation, $aspect_ratio, $grid_size, $image_sizes, $image_cropping $columns, $rows
*/
extract( fluxus_project_type_grid_options( get_queried_object()->term_id ) );
}
$columns = is_numeric( $columns ) ? $columns : 4;
$rows = is_numeric( $rows ) ? $rows : 3;
fluxus_add_html_class( 'layout-portfolio-grid layout-portfolio-grid-' . $orientation );
if ( $orientation !== 'vertical' ) {
fluxus_add_html_class( 'horizontal-page' );
}
get_header();
fluxus_query_portfolio( array(
'fluxus-project-type' => get_query_var( 'fluxus-project-type' )
) );
?>
<div id="main" class="site">
<div class="portfolio-grid js-portfolio-grid" data-aspect-ratio="<?php echo esc_attr( $aspect_ratio ); ?>" data-orientation="<?php echo esc_attr( $orientation ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>" data-rows="<?php echo esc_attr( $rows ); ?>"><?php
while ( have_posts() ) :
the_post();
$project = new PortfolioProject( get_the_ID() );
$project_media = new ProjectMediaMetaBox( get_the_ID() );
$featured = $project_media->get_featured_item();
if ( ! $featured ) continue; // We have no media on this project, nothing to show.
$image = wp_get_attachment_image_src( $featured[ 'attachmentId' ], 'large' );
$image_max = wp_get_attachment_image_src( $featured[ 'attachmentId' ], FLUXUS_HD_IMAGE_SIZE );
if ( isset( $image_sizes[ get_the_ID() ] ) ) {
$size = $image_sizes[ get_the_ID() ];
$max_size = $orientation == 'horizontal' ? $rows : $columns;
$size = $size > $max_size ? $max_size : $size;
} else {
$size = 1;
}
$attr = array(
'class' => "grid-project js-grid-project size-{$size}",
'data-size' => $size,
'data-id' => get_the_ID(),
'data-cropping' => isset( $image_cropping[ get_the_ID() ] ) ?
$image_cropping[ get_the_ID() ] : null
);
?>
<article <?php echo it_array_to_attributes( $attr ); ?>>
<?php
$attr = array(
'href' => get_permalink( get_the_ID() ),
'class' => 'grid-project__preview',
'style' => "background-image: url({$image[ 0 ]})",
'data-max-size' => $image_max[ 0 ],
);
?>
<a <?php echo it_array_to_attributes( $attr ); ?>>
<?php /* Add <img /> tag for SEO and social sharing widgets */ ?>
<img class="hide" src="<?php echo esc_url( $image_max[ 0 ] ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>" />
</a>
<h2 class="grid-project__overlay radial-overlay">
<a class="grid-project__inner"><?php
if ( $project->meta_subtitle ) :
?>
<div class="project-title__prefix project-title__prefix--small">
<?php echo wp_kses_post( $project->meta_subtitle ); ?>
</div>
<?php
endif;
?>
<div class="entry-title"><?php the_title(); ?></div>
<?php if ( post_password_required() ) : ?>
<div class="password-required">
<?php _e( 'Password required', 'fluxus' ); ?>
</div>
<?php endif; ?>
</a>
</h2>
</article><?php
endwhile; ?>
</div>
</div>
<?php
else:
get_header();
endif;
wp_reset_query();
get_footer();
کدهای اصلاح شده مربوط به template-portfolio-grid.php
<?php
/*
Template Name: Grid Portfolio
*/
$columns = false;
$rows = false;
$image_sizes = array();
if ( have_posts() ) :
if ( is_page() ) {
$grid_portfolio = new GridPortfolio( get_the_id() );
// Sets: $orientation, $aspect_ratio, $grid_size, $image_sizes, $image_cropping, $columns, $rows
extract( $grid_portfolio->get_options() );
} else {
extract( GridPortfolio::grid_options() );
/**
* We are on a Project Type page,
* thus we need to check if there is any overriden options.
*
* Sets: $orientation, $aspect_ratio, $grid_size, $image_sizes, $image_cropping $columns, $rows
*/
extract( fluxus_project_type_grid_options( get_queried_object()->term_id ) );
}
$columns = is_numeric( $columns ) ? $columns : 4;
$rows = is_numeric( $rows ) ? $rows : 3;
fluxus_add_html_class( 'layout-portfolio-grid layout-portfolio-grid-' . $orientation );
if ( $orientation !== 'vertical' ) {
fluxus_add_html_class( 'horizontal-page' );
}
get_header();
// Initialize query arguments
$args = array(
'post_type' => 'fluxus_portfolio',
'orderby' => 'rand', // Random order
'posts_per_page' => -1, // Get all posts
);
// If we are on a project type (category) page, filter by the current category
if ( is_tax( 'fluxus-project-type' ) ) {
$current_term = get_queried_object();
$args['tax_query'] = array(
array(
'taxonomy' => 'fluxus-project-type',
'field' => 'term_id',
'terms' => $current_term->term_id,
),
);
}
// Run the custom query
$portfolio_query = new WP_Query( $args );
// Set the global $wp_query to our custom query
global $wp_query;
$wp_query = $portfolio_query;
?>
<div id="main" class="site">
<div class="portfolio-grid js-portfolio-grid" data-aspect-ratio="<?php echo esc_attr( $aspect_ratio ); ?>" data-orientation="<?php echo esc_attr( $orientation ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>" data-rows="<?php echo esc_attr( $rows ); ?>"><?php
while ( have_posts() ) :
the_post();
$project = new PortfolioProject( get_the_ID() );
$project_media = new ProjectMediaMetaBox( get_the_ID() );
$featured = $project_media->get_featured_item();
if ( ! $featured ) continue; // We have no media on this project, nothing to show.
$image = wp_get_attachment_image_src( $featured[ 'attachmentId' ], 'large' );
$image_max = wp_get_attachment_image_src( $featured[ 'attachmentId' ], FLUXUS_HD_IMAGE_SIZE );
if ( isset( $image_sizes[ get_the_ID() ] ) ) {
$size = $image_sizes[ get_the_ID() ];
$max_size = $orientation == 'horizontal' ? $rows : $columns;
$size = $size > $max_size ? $max_size : $size;
} else {
$size = 1;
}
$attr = array(
'class' => "grid-project js-grid-project size-{$size}",
'data-size' => $size,
'data-id' => get_the_ID(),
'data-cropping' => isset( $image_cropping[ get_the_ID() ] ) ?
$image_cropping[ get_the_ID() ] : null
);
?>
<article <?php echo it_array_to_attributes( $attr ); ?>>
<?php
$attr = array(
'href' => get_permalink( get_the_ID() ),
'class' => 'grid-project__preview',
'style' => "background-image: url({$image[ 0 ]})",
'data-max-size' => $image_max[ 0 ],
);
?>
<a <?php echo it_array_to_attributes( $attr ); ?>>
<?php /* Add <img /> tag for SEO and social sharing widgets */ ?>
<img class="hide" src="<?php echo esc_url( $image_max[ 0 ] ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>" />
</a>
<h2 class="grid-project__overlay radial-overlay">
<a class="grid-project__inner"><?php
if ( $project->meta_subtitle ) :
?>
<div class="project-title__prefix project-title__prefix--small">
<?php echo wp_kses_post( $project->meta_subtitle ); ?>
</div>
<?php
endif;
?>
<div class="entry-title"><?php the_title(); ?></div>
<?php if ( post_password_required() ) : ?>
<div class="password-required">
<?php _e( 'Password required', 'fluxus' ); ?>
</div>
<?php endif; ?>
</a>
</h2>
</article><?php
endwhile; ?>
</div>
</div>
<?php
else:
get_header();
endif;
wp_reset_query();
get_footer();
ما تغییرات را روی قالبتون انجام داده ایم و نیازی نیست که مجدد انجام بدید، تنها اگر زمانی قالب سایتتون و آپدیت کردید لازم است که این تغییرات را مجدد اعمال کنید، البته ممکن است که در زمان آپدیت قالب کدهای این صفحه نیز آپدیت شده باشند که با تغییرات مجدد قالب سایت بهم ریخته شود، ولی باید تست کنید چنانچه پس از آپدیت و تغییرات این صفحه مشکلی در سایت ایجاد نشد که خوبه اگر مشکلی ایجاد شد مجدد اطلاع بدید تا بررسی و رفع شود.