Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Konrad Pilch
Konrad Pilch
2,435 Points

[SOLVED]Wordpress displays directory but not image

wordpress displays directory but not image.

Portfolio Lorem ipsum dolor sit amet consctureo.

http://localhost:8888/wp-aurelian-portfolio/wp-content/uploads/2015/12/IMG_7092.jpg eBay

http://localhost:8888/wp-aurelian-portfolio/wp-content/uploads/2015/12/Z10HSIQB1D.jpg WordPress

http://localhost:8888/wp-aurelian-portfolio/wp-content/uploads/2015/12/Screen-Shot-2015-12-19-at-18.23.15.png Adolino

 <div> <?php echo get_field('cover_image_portfolio'); ?></div>

Using Custome Fields, i set it to image and then tried all.

Konrad Pilch
Konrad Pilch
2,435 Points

It displays the title

Konrad Pilch
Konrad Pilch
2,435 Points

Or do i need to put it here to work?

//Portflio
// Our custom post type function
function create_posttype() {

    register_post_type( 'portfolio',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Portfolio' ),
                'singular_name' => __( 'portfolio piece' )

            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'portfolio piece'),
            'menu_icon'           => 'dashicons-welcome-add-page', // picture on the left [pic]Portfolio
        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

1 Answer

Konrad Pilch
Konrad Pilch
2,435 Points
 <img  style="background-image:url(<?php echo get_field('post_image_portfolio'); ?>);">