dear Derek Herman
Unfortunately above codes don’t work for me.I am giving you whole codes whatever i used in my theme.
I registered meta box fields which are below:
function custom_meta_boxes() {
$my_meta_box = array(
'id' => 'demo_meta_box',
'title' => __( 'Theme Informations', 'wpfreeware' ),
'desc' => '',
'pages' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'label' => __( 'Theme Promo Description', 'wpfreeware' ),
'id' => 'theme_promo',
'type' => 'textarea_simple',
'desc' => __( 'Write a attractive description about the theme here for archieve page.Maximum Word length is 18.', 'wpfreeware' ),
'rows' => '5'
),
array(
'label' => __( 'Background Css Class / Animation', 'wpfreeware' ),
'id' => 'css_classes',
'type' => 'text',
'desc' => __( '1. bounceInRight / bounceInLeft <br/> 2. bg1(light blue), bg2(dark blue), bg3(chocolate), bg4(dark gray), bg5(light gray), bg6(orange), bg7(black)', 'wpfreeware' )
),
array(
'label' => __( 'Preview Link', 'wpfreeware' ),
'id' => 'preview_link',
'type' => 'text',
'desc' => __( 'Put the theme preview link here', 'wpfreeware' )
),
array(
'label' => __( 'Upload Theme', 'wpfreeware' ),
'id' => 'download_file',
'type' => 'upload',
'desc' => __( 'Upload the theme file here.', 'wpfreeware' )
),
array(
'id' => 'my_slider',
'label' => __( 'Theme Screenshots', 'wpfreeware' ),
'type' => 'gallery',
'desc' => __( 'Upload this theme screenshots here.', 'wpfreeware' )
)
)
);
if ( function_exists( 'ot_register_meta_box' ) )
ot_register_meta_box( $my_meta_box );
The following codes i used in functions.php
function custom_get_attachment_id( $guid ) {
global $wpdb;
/* nothing to find return false */
if ( ! $guid )
return false;
/* get the ID */
$id = $wpdb->get_var( $wpdb->prepare(
"
SELECT p.ID
FROM $wpdb->posts p
WHERE p.guid = %s
AND p.post_type = %s
",
$guid,
'attachment'
) );
/* the ID was not found, try getting it the expensive WordPress way */
if ( $id == 0 )
$id = url_to_postid( $guid );
return $id;
}
And last, this piece of codes i used to display the images in slider into single.php .
<?php
if ( function_exists( 'ot_get_option' ) ) {
$images = explode( ',', ot_get_option( 'my_slider', '' ) );
if ( !empty( $images ) ) {
foreach( $images as $id ) {
if ( !empty( $id ) ) {
$full_img_src = wp_get_attachment_image_src( $id, 'single-page-slider-img' );
$thumb_img_src = wp_get_attachment_image_src( $id, 'single-page-slider-thumb-img' );
echo '<div data-thumb="' . $thumb_img_src . '" data-src="' . $full_img_src . '"></div>';
}
}
}
}
?>
Am i missing something? I know PHP basic,I am not expert in PHP.
Please if you can,give me solution to display the images.
Thank You!