Portfolio tutorial not working.
-
Well i have been trying to get a portfolio template working for my wordpress theme i have been making from scratch and yet another thing will not work for me, i have tried a few different tutorials to get it working but none of them work as they should, all that i can get to display is a title of one of the posts which should be shown, it will not show the content or any of the second post and for some reason the footer disapears also. I am getting very frustrated with things not working when they should from what other people have said on the websites…
Here is the code i have entered in functions.php and portfolio.php:
functions.php:
<?php add_action('init', 'create_portfolio'); function create_portfolio() { $portfolio_args = array( 'label' => __('Portfolio'), 'singular_label' => __('Portfolio'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => true, 'supports' => array('title', 'editor', 'thumbnail') ); register_post_type('portfolio',$portfolio_args); } ?> <?php add_action("admin_init", "add_portfolio"); add_action('save_post', 'update_website_url'); function add_portfolio(){ add_meta_box("portfolio_details", "Portfolio Options", "portfolio_options", "portfolio", "normal", "low"); } function portfolio_options(){ global $post; $custom = get_post_custom($post->ID); $website_url = $custom["website_url"][0]; ?> <div id="portfolio-options"> <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" /> </div><!--end portfolio-options--> <?php } function update_website_url(){ global $post; update_post_meta($post->ID, "website_url", $_POST["website_url"]); } ?> <?php add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns"); add_action("manage_posts_custom_column", "portfolio_columns_display"); function portfolio_edit_columns($portfolio_columns){ $portfolio_columns = array( "cb" => "<input type=\"checkbox\" />", "title" => "Project Title", "description" => "Description", ); return $portfolio_columns; } function portfolio_columns_display($portfolio_columns){ switch ($portfolio_columns) { case "description": the_excerpt(); break; } } ?>And the portfolio.php:
<?php /* Template Name: Portfolio */ ?> <?php get_header(); ?> <div id="content"> <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 10)); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $custom = get_post_custom($post->ID); $screenshot_url = $custom["screenshot_url"][0]; $website_url = $custom["website_url"][0]; ?> <div id="portfolio-item"> <h1><?php the_title(); ?></h1> <a>"><?php the_post_thumbnail(); ?> </a> <?php the_content(); ?> </div> <?php endwhile; ?> </div><!-- #content --> <?php get_footer(); ?>
The topic ‘Portfolio tutorial not working.’ is closed to new replies.