How to add post title to header area in custom single.php?

  • Resolved
    Posted in: Jupiter  

  • Member
    Quel13
    December 10, 2013 at 12:22 am #9757

    Hi all,

    I created a custom post type (Memes) to handle the display and organization of images on the site. Just for this post type, I didn’t want the author info or related posts so I deleted that code from single.php and renamed the file to single-memes.php (for the memes custom post type).

    It worked perfectly but the post title isn’t showing up in the usual header area. I know I probably have to drag over some code from theme-class.php but I don’t know quite what to copy in the line 253 area and then where to put it in single-meme.php.

    Here’s what my single-meme.php file looks like:


    <?php

    global $post;
    $options = theme_option(THEME_OPTIONS);
    $single_layout = get_post_meta( $post->ID, '_layout', true );

    if($single_layout == 'default' || empty($single_layout)) {
    $single_layout = $options['single_layout'];
    }
    $image_height = $options['single_featured_image_height'];

    $grid_width = $options['grid_width'];
    $content_width = $options['content_width'];

    if( $single_layout=='full' ) {
    $image_width = $grid_width;
    }else {
    $image_width = ( ( $content_width / 100 ) * $grid_width );
    }

    function social_networks_meta() {
    $image_src_array = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full', true );
    $output = '<meta property="og:image" content="'.$image_src_array[ 0 ].'"/>'. "\n";
    $output .= '<meta property="og:url" content="'.get_permalink().'"/>'. "\n";
    $output .= '<meta property="og:title" content="'.get_the_title().'"/>'. "\n";
    echo $output;
    }
    add_action('wp_head', 'social_networks_meta');

    get_header(); ?>

    <?php if($options['blog_prev_next'] == 'true') : ?>
    <nav class="mk-blog-pagination mk-loop-next-prev">
    <?php

    $next_post = get_next_post();
    if ( !empty( $next_post ) ) {
    echo 'ID ).'" title="'.get_the_title( $next_post->ID ).'" class="mk-next-post"><i class="mk-icon-chevron-right"></i>';
    }

    $prev_post = get_previous_post();
    if ( !empty( $prev_post ) ) {
    echo 'ID ).'" title="'.get_the_title( $prev_post->ID ).'" class="mk-prev-post"><i class="mk-icon-chevron-left"></i>';
    }

    if(4==3){paginate_links(); posts_nav_link(); next_posts_link(); previous_posts_link();}
    ?>
    </nav>
    <?php endif; ?>

    <div id="theme-page">

    <?php if ( have_posts() ) while ( have_posts() ) : the_post();

    $post_type = get_post_meta( $post->ID, '_single_post_type', true );
    $image_src_array = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full', true );
    if($options['blog_single_img_crop'] == 'true') {
    $image_src = theme_image_resize( $image_src_array[ 0 ], $image_width, $image_height);
    } else {
    $image_src['url'] = $image_src_array[ 0 ];
    }

    ?>

    <div class="theme-page-wrapper mk-blog-single <?php echo $single_layout; ?>-layout vc_row-fluid mk-grid row-fluid">
    <div class="theme-content">
    <article id="<?php the_ID(); ?>" <?php post_class(); ?>>

    <?php if($options['single_meta_section'] == 'true' && get_post_meta( $post->ID, '_disable_meta', true ) != 'false') : ?>
    <div class="blog-single-meta">
    <div class="mk-blog-author"><?php _e('By', 'mk_framework'); ?> <?php the_author_posts_link(); ?></div>
    <time class="mk-post-date" datetime="<?php the_time( 'F jS, Y' ) ?>">
    <?php _e('Posted', 'mk_framework'); ?> "><?php the_time( 'F jS, Y' ) ?>
    </time>
    <div class="mk-post-cat"> <?php _e('In', 'mk_framework'); ?> <?php the_category( ', ' ) ?></div>
    </div>
    <?php endif; ?>

    <div class="single-social-section">

    <div class="mk-love-holder"><?php echo mk_love_this(); ?></div>
    #comments" class="blog-modern-comment"><i class="mk-moon-bubble-9"></i><span> <?php echo comments_number( '0', '1', '%'); ?></span>

    <div class="blog-share-container">
    <div class="blog-single-share mk-toggle-trigger"><i class="mk-moon-share"></i></div>
    <ul class="single-share-box mk-box-to-trigger">

  • " data-url="<?php echo get_permalink(); ?>" href="#"><i class="mk-jupiter-icon-simple-facebook"></i>
  • " data-url="<?php echo get_permalink(); ?>" href="#"><i class="mk-jupiter-icon-simple-twitter"></i>
  • " data-url="<?php echo get_permalink(); ?>" href="#"><i class="mk-jupiter-icon-simple-googleplus"></i>
  • " data-title="<?php the_title(); ?>" data-url="<?php echo get_permalink(); ?>" href="#"><i class="mk-jupiter-icon-simple-pinterest"></i>
  • </div>

    <div class="clearboth"></div>
    </div>
    <div class="clearboth"></div>
    <?php

    if($options['single_disable_featured_image'] == 'true' && get_post_meta( $post->ID, '_disable_featured_image', true ) != 'false') :

    if($post_type == 'image' || $post_type == 'portfolio') { ?>
    <?php if(has_post_thumbnail()) : ?>
    <div class="single-featured-image">
    " title="<?php the_title(); ?>" src="<?php echo $image_src['url']; ?>" height="<?php echo $image_height; ?>" width="<?php echo $image_width; ?>" />
    </div>
    <?php endif; ?>
    <?php } elseif($post_type == 'video') {
    $skin_color = $options['skin_color'];
    $video_id = get_post_meta( $post->ID, '_single_video_id', true );
    $video_site = get_post_meta( $post->ID, '_single_video_site', true );

    if($video_site =='vimeo') {
    echo '<div style="width:'.$image_width.'px;" class="mk-video-wrapper"><div class="mk-video-container"><iframe src="http://player.vimeo.com/video/'.$video_id.'?title=0&byline=0&portrait=0&color='.str_replace("#", "", $skin_color).'" width="'.$image_width.'" height="'.$image_height.'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>';
    }

    if($video_site =='youtube') {
    echo '<div style="width:'.$image_width.'px;" class="mk-video-wrapper"><div class="mk-video-container"><iframe src="http://www.youtube.com/embed/'.$video_id.'?showinfo=0&theme=light&color=white&rel=0" frameborder="0" width="'.$image_width.'" height="'.$image_height.'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>';
    }

    if($video_site =='dailymotion') {
    echo '<div style="width:'.$image_width.'px;" class="mk-video-wrapper"><div class="mk-video-container"><iframe src="http://www.dailymotion.com/embed/video/'.$video_id.'?logo=0" frameborder="0" width="'.$image_width.'" height="'.$image_height.'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>';
    }

    } elseif($post_type == 'audio') {
    $audio_id = mt_rand( 99, 999 );
    $mp3_file = get_post_meta( $post->ID, '_mp3_file', true );
    $ogg_file = get_post_meta( $post->ID, '_ogg_file', true );
    $audio_author = get_post_meta( $post->ID, '_single_audio_author', true );
    wp_enqueue_script( 'jquery-jplayer' );
    $image_src_array = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full', true );
    $image_src = theme_image_resize( $image_src_array[ 0 ], 170, 170);

    /* Random Color variations for Audio box background */
    $audio_box_color = array('#00c8d7', '#e1ba05', '#da4c26','#f56a5f', '#00b89a', '#95c76a','#acacac', '#d19760');
    $random_colors = array_rand($audio_box_color, 1);
    $has_image = '';

    echo '<script type="">

    jQuery(document).ready(function($) {

    jQuery("#jquery_jplayer_'.$audio_id.'").jPlayer({
    ready: function () {
    $(this).jPlayer("setMedia", {';
    if ( $mp3_file ) {
    echo 'mp3: "'.$mp3_file.'",';
    }
    if ( $ogg_file ) {
    echo 'ogg: "'.$ogg_file.'",';
    }

    echo ' });
    },
    play: function() { // To avoid both jPlayers playing together.
    $(this).jPlayer("pauseOthers");
    },
    swfPath: "'.THEME_JS.'",
    supplied: "mp3, ogg",
    cssSelectorAncestor: "#jp_container_'.$audio_id.'",
    wmode: "window"
    });

    })

    </script>';

    echo '<div class="mk-audio-section" style="background-color:'.$audio_box_color[$random_colors].'">';
    if ( has_post_thumbnail() ) {
    echo ''.get_the_title().'';
    $has_image = 'audio-has-img';
    }

    echo '<div data-mp3="'.$mp3_file.'" data-ogg="'.$ogg_file.'" id="jquery_jplayer_'.$audio_id.'" class="jp-jplayer mk-blog-audio"></div>
    <div id="jp_container_'.$audio_id.'" class="jp-audio '.$has_image.'">
    <div class="jp-type-single">
    <div class="jp-gui jp-interface">
    <div class="jp-time-holder">
    <div class="jp-current-time"></div>
    <div class="jp-duration"></div>
    </div>

    <div class="jp-progress">
    <div class="jp-seek-bar">
    <div class="jp-play-bar"></div>
    </div>
    </div>
    <div class="jp-volume-bar">
    <i class="mk-moon-volume-mute"></i><div class="inner-value-adjust"><div class="jp-volume-bar-value"></div></div>
    </div>
    <ul class="jp-controls">

  • <i class="mk-icon-play"></i>
  • <i class="mk-icon-pause"></i>
  • ';
    if($audio_author) {
    echo '<span class="mk-audio-author">'.$audio_author.'</span>';
    }
    echo '</div>
    <div class="jp-no-solution">
    <span>Update Required</span>
    To play the media you will need to either update your browser to a recent version or update your Flash plugin.
    </div>
    </div></div><div class="clearboth"></div></div>
    ';
    }

    endif;

    ?>

    <div class="clearboth"></div>
    <div class="mk-single-content">
    <?php the_content(); ?>
    </div>
    <?php wp_link_pages('before=<div class="mk-page-links">'.__('Pages:', 'mk_framework').'&after=</div>'); ?>

    <div class="single-back-top">
    <i class="mk-icon-chevron-up"></i><?php _e('Back to Top', 'mk_framework'); ?>
    </div>

    <div class="clearboth"></div>

    <?php
    if($options['enable_blog_single_comments'] == 'true') :
    comments_template( '', true );
    endif;
    ?>
    </article>
    <div class="clearboth"></div>
    </div>
    <?php endwhile; ?>
    <?php if($single_layout != 'full') get_sidebar(); ?>
    <div class="clearboth"></div>
    </div>

    </div>
    <?php get_footer(); ?>

    Here’s is an example Meme post where the post title isn’t showing up in the header area: http://dev.gearheaddiva.com/memes/education-parenting-done-right/

Sorry, this forum is for verified users only. Please Login or Register to continue