File: /var/www/html/wp-content/themes/exertio/custom-offer-modal.php
<?php
$current_user_id = get_current_user_id();
$posts_per_page=fl_framework_get_options('custom_offer_services_limit');
if (is_user_logged_in()) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$offset = ($paged - 1) * $posts_per_page; // Calculate offset based on current page
$query_args = array(
'author__in' => array($current_user_id),
'post_type' => 'services',
'meta_query' => array(
array(
'key' => '_service_status',
'value' => 'active',
'compare' => '=',
),
),
'paged' => $paged,
'post_status' => 'publish',
'posts_per_page'=> $posts_per_page,
'offset' => $offset, // Include the offset parameter
);
$the_query = new WP_Query($query_args);
$total_count = $the_query->found_posts;
?>
<div class="modal fade er-create-offer-modal" id="custom-offer-modal" tabindex="-1" aria-labelledby="createOfferModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="createOfferModalLabel"><?php esc_html_e('Create a Custom Offer', 'exertio_theme'); ?></h5>
<button type="button" class="close" data-dismiss="modal" id="close_form" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<input type="hidden" id='offer_receiver_id'>
<input type="hidden" id='offer_seller_id'>
<!-- Place the code for displaying services here -->
<div class="modal-body">
<ul class="er-gigs-list">
<?php
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
$sid = get_the_ID();
$image_id = get_post_meta($sid, '_service_attachment_ids', true);
$image_link = wp_get_attachment_image_src($image_id, 'thumbnail');
// print_r($image_link);
// $logo_path = get_template_directory_uri() . '/images/custom-offer.jpg';
$image = wp_get_attachment_image($image_id, 'thumbnail', $image_link);
?>
<li id="custom_offer" data-id="<?php echo esc_attr(get_the_ID()); ?>" data-image="<?php echo esc_attr($image_id); ?>">
<div class="er-gig-box">
<div class="img-box">
<?php
if (is_array($image_link) && !empty($image_link))
{
echo '<img src="' . esc_url($image_link[0]) . '" alt="' . esc_attr('hlo') . '">';
}
else {
$custom_offer_default_img = fl_framework_get_options('custom_offer_default_img');
$default_image_url = is_array($custom_offer_default_img) && isset($custom_offer_default_img['url']) ? $custom_offer_default_img['url'] : '';
echo '<img src="' . esc_url($default_image_url) . '" alt="' . esc_attr('Default Image') . '">';
}
?>
</div>
<div class="meta-box">
<h6 class="pro-name title"><?php echo esc_html(get_the_title()); ?></h6>
</div>
</div>
</li>
<?php
}
}
?>
</ul>
<!-- Display Pagination Buttons -->
<div class="pagination-buttons fl-navigation">
<ul class="pagination justify-content-end">
<?php
$max_pages = $the_query->max_num_pages;
$current_page = get_query_var('paged') ? get_query_var('paged') : 1;
// Output individual page links
for ($i = 1; $i <= $max_pages; $i++) {
echo '<li class="' . ($current_page == $i ? 'active' : '') . '">';
echo '<a class="load-page" href="#" data-paged="' . esc_attr($i) . '">' . esc_html($i) . '</a>';
echo '</li>';
}
?>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php
wp_reset_postdata();
} else {
echo exertio_redirect(home_url('/'));
}