Advertisement
cbanowsky

Not Pulling from Post

Sep 30th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. //Custom Post Type
  2. register_post_type('inf_main_feature', array(
  3. 'labels' => array(
  4. 'name' => 'Main Featured',
  5. 'singular_name' => 'Main Featured',
  6. 'add_new' => __( 'Add New' ),
  7. 'add_new_item' => __( 'Add New Feature' ),
  8. 'view_item' => 'View Feature',
  9. 'edit_item' => 'Edit Story',
  10. 'new_item' => __('New Featire'),
  11. 'view_item' => __('View New Feature'),
  12. 'search_items' => __('Search Features'),
  13. 'not_found' => __('No entries found'),
  14. 'not_found_in_trash' => __('No entries found in Trash'),
  15. ),
  16. 'public' => true,
  17. 'exclude_from_search' => true,
  18. 'show_ui' => true,
  19. 'capability_type' => 'post',
  20. 'hierarchical' => false,
  21. '_edit_link' => 'post.php?post=%d',
  22. 'rewrite' => array(
  23. "slug" => "homebox",
  24. "with_front" => false,
  25. ),
  26. 'query_var' => true,
  27. 'supports' => array('title', 'editor', 'page-attributes', 'thumbnail'),
  28. ));
  29.  
  30. //Custom Fields
  31.  
  32. Carbon_Container::factory('custom_fields', __('Feature Options', 'inf'))
  33. ->show_on_post_type('inf_main_feature')
  34. ->add_fields(array(
  35. Carbon_Field::factory('text', 'feature_url', 'The Link'),
  36. Carbon_Field::factory('attachment', 'main_image', 'Main Image')
  37. ->help_text('Image Dimensions - 600 × 600 pixels.')
  38. ));
  39.  
  40. // Main Feature
  41. function inf_feature() {
  42. $args = array (
  43. 'post_type' => 'inf_main_feature',
  44. 'posts_per_page' => 1
  45. );
  46. $feature = get_post($args)[0]->ID;
  47. $feature_link = get_post_meta($feature->ID, 'feature_url', true);
  48. $main_boxID = get_post_meta($feature->ID, 'main_image', full);
  49. $main_image = get_post($main_boxID[0])->guid;
  50. ?>
  51. <div class="main_feature_container">
  52. <div class="main_feature">
  53. <a href="<?php echo $feature_link ?>">
  54. <img src="<?php echo $main_image ?>" />
  55. </a>
  56. </div>
  57. <?php
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement