Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to show specific sized images through wordpress option tree meta box
- // register your gallery type meta box and use the following code to display images.
- if ( function_exists( 'ot_get_option' ) ) {
- $images = explode( ',', get_post_meta( get_the_ID(), 'field-id', true ) );
- if ( !empty( $images ) ) {
- foreach( $images as $id ) {
- if ( !empty( $id ) ) {
- $full_img_src = wp_get_attachment_image_src( $id, 'your-image-size' );
- $thumb_img_src = wp_get_attachment_image_src( $id,'your-image-size' );
- echo '
- ';
- }
- }
- }
- }
- In line no 4 the field-id is your meta box id.
- You can define as much as image sizes you want with your-image-size which you can see in the line no 08 & 09 . The your-image-size is your image id which you created by add_image_size() function in the functions.php .
- Thank You!
- // source link:http://www.wpfreeware.com/tutorial/how-to-show-custom-sized-images-through-wordpress-option-tree/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement