Install the artgallery-toolbox
plugin
Paste This code in functions.php
and add place the inc
folder in the theme directory
/* Amit Custom Code Start Here */
add_action('wp_ajax_loadmore', 'artchive_loadmore_ajax_handler');
add_action('wp_ajax_nopriv_loadmore', 'artchive_loadmore_ajax_handler');
function artchive_loadmore_ajax_handler()
{
$paged = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
$partner_slug = isset($_REQUEST['partner_slug']) ? $_REQUEST['partner_slug'] : 1;
$args = array(
'post_type' => 'artgallery',
'posts_per_page' => 6,
'paged' => $paged,
'orderby' => 'title',
'order' => 'ASC',
'relation' => 'OR',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'partners',
'terms' => $partner_slug,
'field' => 'slug'
)
)
);
$partner_query = new WP_Query($args);
if ($partner_query->have_posts()) {
while ($partner_query->have_posts()) {
$partner_query->the_post();
$thumbnail = get_post_meta(get_the_ID(), 'thumbnail', true);
?>
<div class="col-md-4 col-xs-12 col-sm-4 single_partner_resource">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $thumbnail; ?>"
alt="<?php the_title(); ?>">
<h2><?php the_title(); ?></h2>
</a>
</div>
<?php
}
}
wp_reset_query();
wp_die();
}
add_action('wp_ajax_request_download', 'artgallery_request_download_ajax_handler');
add_action('wp_ajax_nopriv_request_download', 'artgallery_request_download_ajax_handler');
function artgallery_request_download_ajax_handler()
{
$email = $_REQUEST['email'];
$art_title = $_REQUEST['art_title'];
$art_link = $_REQUEST['art_link'];
$to = get_option('admin_email');
$subject = 'Request to download resource from ' . $email;
$body = $email . ' has requested to download <strong>'. $art_title .'</strong> from <a href="'.$art_link.'" target="_blank">'.$art_link.'</a>';
if(empty($to) || empty($art_title) || empty($art_link)){
print_r(0);
wp_die();
}
else{
$headers = array('Content-Type: text/html; charset=UTF-8','From: SRHR Partnership Art gallery <'.$email.'>');
wp_mail($to, $subject, $body, $headers);
print_r(1);
wp_die();
}
}
/**
* Get the bootstrap!
* (Update path to use cmb2 or CMB2, depending on the name of the folder.
* Case-sensitive is important on some systems.)
*/
require_once __DIR__ . '/inc/CMB2/init.php';
require_once __DIR__ . '/inc/CMB2/metabox.php';
/* Amit Custom Code End Here */