About the Download

/***********************************************
/wp-content/themes/marketify-child/functions.php
***********************************************/
function product_list_callback($atts)
{
$atts = shortcode_atts(
[
‘title’ => ”,
‘limit’ => ’10’,
‘types’ => ”,
‘pagination’ => ‘no’,
], $atts, ‘product_list’);

ob_start();

$args = [
‘post_type’ => ‘download’,
‘post_status’ => ‘publish’,
‘orderby’ => ‘ID’,
‘order’ => ‘DESC’,
];

if ($atts[‘types’] != ”)
{
$types = explode(‘|’, $atts[‘types’]);

$args[‘tax_query’][] = [
‘taxonomy’ => ‘types’,
‘field’ => ‘slug’,
‘terms’ => $types,
];
}

if ($atts[‘limit’] != ”)
{
$args[‘posts_per_page’] = $atts[‘limit’];
}

$args[‘paged’] = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;

$arrProduct = new WP_Query($args);

wp_reset_query();

if ($arrProduct->found_posts > 0)
{
$site_url = site_url();

if ($atts[‘title’] != ”)
{
echo ‘<h3 class=”widget-title widget-title–home section-title”><span>’ . $atts[‘title’] . ‘</span></h3>’;
}
?>

<table class=”table fes-table table-condensed table-striped” id=”help_request_list”>

<thead>
<tr>
<th width=”40%”>Title</th>
<th>Price</th>
<th>Image</th>
<th>User</th>
<th>Date</th>
</tr>
</thead>

<tbody>
<?php
foreach ($arrProduct->posts as $product)
{
$product_link = get_the_permalink($product->ID);
$img_url = get_the_post_thumbnail_url($product->ID);
$user_name = get_userdata($product->post_author);
$date = date_create($product->post_date);
?>
<td class=”fes-order-list-td widget”>
<a href=”<?php echo $product_link ?>” title=”View” class=”view-order-fes”><?php echo $product->post_title; ?></a>
</td>

<td class=”fes-order-list-td”><?php echo edd_price($product->ID); ?></td>

<?php
if ($img_url != ”)
{
echo ‘<td><img width=”50″ src=”‘ . $img_url . ‘” ></td>’;
}
else
{
echo ‘<td></td>’;
}
?>

<td><?php echo $user_name->data->display_name; ?></td>

<td><?php echo date_format($date, “Y-m-d”); ?></td>

</tr>
<?php
}
?>
</tbody>
</table>

<?php
if ($atts[‘pagination’] == ‘yes’)
{
if ($arrProduct->max_num_pages > 1)
{
echo ‘<div class=”product_pagination”>’;
cm_pagination($arrProduct->max_num_pages, 2);
echo ‘</div>’;
}
}
}

return ob_get_clean();
}

add_shortcode(‘product_list’, ‘product_list_callback’);

function cm_pagination($pages = ”, $range = 2)
{
$showitems = ($range * 2) + 1;

global $paged;

if (empty($paged))
{
$paged = 1;
}

if ($pages > 1)
{
echo ‘<ul class=”pagination”>’;

echo “<li class=\”page-item\”><a class=’page-link’ href='” . get_pagenum_link($paged – 1) . “‘>Previous</a></li>”;

for ($i = 1; $i <= $pages; $i++)
{
if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged – $range – 1) || $pages <= $showitems))
{
if ($paged == $i)
{
print ‘<li class=”page-item active”><a class=”page-link” href=”‘ . get_pagenum_link($i) . ‘” >’ . $i . ‘</a></li>’;
}
else
{
print ‘<li class=”page-item”><a class=”page-link” href=”‘ . get_pagenum_link($i) . ‘” >’ . $i . ‘</a></li>’;
}
}
}

$prev_page = get_pagenum_link($paged + 1);
if (($paged + 1) > $pages)
{
$prev_page = get_pagenum_link($paged);
}
else
{
$prev_page = get_pagenum_link($paged + 1);
}

echo ‘<li class=”page-item”><a class=”page-link” href=”‘ . $prev_page . ‘”>Next</a></li>’;
echo ‘</ul>’;
}
}

/***************************
How to add shortcode in Page

Note :: All parameter has been optional if you need than pass.
***************************/
‘[‘product_list types=”bug-fix” pagination=”yes” title=”Product List”‘]’

Types
Date Created 14/08/2019
Licence
Support Time(in Minutes)
Support Details