0
//Custom Post Type
register_post_type('inf_main_feature', array(
      'labels' => array(
            'name'   => 'Main Featured',
            'singular_name' => 'Main Featured',
            'add_new' => __( 'Add New' ),
            'add_new_item' => __( 'Add New Feature' ),
            'view_item' => 'View Feature',
            'edit_item' => 'Edit Story',
            'new_item' => __('New Featire'),
            'view_item' => __('View New Feature'),
            'search_items' => __('Search Features'),
            'not_found' =>  __('No entries found'),
            'not_found_in_trash' => __('No entries found in Trash'),
    ),
    'public' => true,
    'exclude_from_search' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    '_edit_link' =>  'post.php?post=%d',
    'rewrite' => array(
            "slug" => "homebox",
            "with_front" => false,
    ),
    'query_var' => true,
    'supports' => array('title', 'editor', 'page-attributes', 'thumbnail'),
));

 //Custom Fields

 Carbon_Container::factory('custom_fields', __('Feature Options', 'inf'))
     ->show_on_post_type('inf_main_feature')
->add_fields(array(
              Carbon_Field::factory('text', 'feature_url', 'The Link'),
            Carbon_Field::factory('attachment', 'main_image', 'Main Image')
                    ->help_text('Image Dimensions - 600 × 600 pixels.')
    ));

// Main Feature
function inf_feature() {
  $args = array (
'post_type' => 'inf_main_feature',
 'posts_per_page' => 1
);
  $feature = get_post($args)[0]->ID;
 $feature_link = get_post_meta($feature->ID, 'feature_url', true);
 $main_boxID =  get_post_meta($feature->ID, 'main_image', full);
  $main_image = get_post($main_boxID[0])->guid;
 ?>

My HTML


  div class="main_feature_container"
      div class="main_feature"
      a href="php echo $feature_link"
        img src="php echo $main_image"
      /a
  /div

forget the tags <> and < ? etc... I am a noob with this editor and cant get it to render properly.

i cannot get this to pull the image or the link from this custom post type. Any help would be appreciated.

1 Answer 1

0

Try this way, may help you. I just fetch from a specific post 's image from a specific Post Type called "gameshowwarriorsw".

        $gameShowWarriorsWorld = new WP_Query( 'post_type=gameshowwarriorsw&orderby=date&order=DESC&p=371' );   
        while ($gameShowWarriorsWorld->have_posts()) : $gameShowWarriorsWorld->the_post();


        $postTitle = get_the_title();
        $postid = get_the_id();
        $postContent    = get_the_content();



    ?>

        <li>    <a href="#" onclick="return get_inzenwarriorhero(<?php echo $postid ; ?>);">
                     <?php the_post_thumbnail(array(219,143)); ?>
                </a> 
        </li>
    <?php 
        endwhile;
       wp_reset_query();
    ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.