Skip to content

Instantly share code, notes, and snippets.

@RickeyMessick
Last active July 27, 2020 09:20
Show Gist options
  • Save RickeyMessick/b80bb541c1892af02b9a to your computer and use it in GitHub Desktop.
Save RickeyMessick/b80bb541c1892af02b9a to your computer and use it in GitHub Desktop.
wp import all - soliloquy slider CPT import
/**
* WP Import All cpt soliloquy slider
*
* @param $pid – the ID of the post/page/Custom Post Type that was just created.
* @param $attid – the ID of the attachment
* @param $image_filepath – the full path to the file: C:\path\to\wordpress\wp-content\uploads\2010\05\filename.png
*
*/
add_action('pmxi_gallery_image', 'my_gallery_image', 10, 3);
function my_gallery_image($pid, $attid, $image_filepath) {
$image_url_path = 'http://[url]/wp-content/uploads/2014/09/' . basename($image_filepath);
$data = get_post_meta( $pid, '_sol_slider_data', true );
if ( empty( $data ) ) {
$data = array(
'id' => $pid,
'config' => array(),
'slider' => array(),
'status' => 'active'
);
$data['config']['type'] = 'default';
$data['config']['slider_size'] = 'default';
$data['config']['slider_theme'] = 'metro';
$data['config']['slider_width'] = '656';
$data['config']['slider_height'] = '300';
$data['config']['position'] = 'center';
$data['config']['transition'] = 'fade';
$data['config']['duration'] = '5000';
$data['config']['speed'] = '400';
$data['config']['gutter'] = '20';
$data['config']['auto'] = '1';
$data['config']['smooth'] = '1';
$data['config']['arrows'] = '1';
$data['config']['control'] = '1';
$data['config']['pauseplay'] = '0';
$data['config']['hover'] = '0';
$data['config']['slider'] = '1';
$data['config']['mobile'] = '1';
$data['config']['mobile_width'] = '600';
$data['config']['mobile_height'] = '200';
$data['config']['keyboard'] = '1';
$data['config']['css'] = '1';
$data['config']['loop'] = '1';
$data['config']['random'] = '0';
$data['config']['delay'] = '0';
$data['config']['start'] = '0';
$data['config']['classes'] = '';
$data['config']['title'] = '';
$data['config']['slug'] = '';
}
$data['slider'][$attid] = array(
'status' => 'active',
'id' => $attid,
'src' => $image_url_path,
'title' => get_the_title( $attid ),
'link' => '',
'linktab' => '',
'alt' => get_the_title( $attid ),
'caption' => '',
'filter' => '',
'type' => 'image'
);
update_post_meta($pid, '_sol_slider_data', $data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment