• Hi,

    I am writing my own wordpress blog theme and am trying to write the functions php code based on some tutorials and looking at the code from other themes. However, recently I run into the problem of being unable to show pingbacks and trackbacks. When I run a test post for pingbacks and trackbacks, I am linked to a new post page, however, the dashboard disappears as well as my sidebar widget.

    For reference, here is my functions php. Can anybody tell me if there is something missing or amiss that would prevent me from properly seeing pingbacks and trackbacks in the comment list as well as preventing the post from getting the sidebar php?

    <?php
    
    define('THEMEROOT', get_stylesheet_directory_uri());
    define('IMAGES', THEMEROOT . '/images');
    
    if ( function_exists('register_sidebar') )
    register_sidebar();
    
    function arphabet_widgets_init(){
    register_sidebar(array(
    'top-menu' => __('Top Menu', 'PLUM_THEME-framework'),
    'main-menu' => __('Main Menu', 'PLUM_THEME-framework'),
    ));
    }
    add_action('widgets_init', 'arphabet_widgets_init');
    
    if (function_exists('register_sidebar')) {
    register_sidebar(
    array(
    'name' => __('Sidebar', 'PLUM_THEME-framework'),
    'id' => 'sidebar',
    'description' => __('The main sidebar area', 'PLUM_THEME-framework'),
    'before_widget' => '<div class="sidebar-widget">',
    'after_widget' => '</div> <!--end sidebar-widget-->',
    'before_title' => '<h4>',
    'after_title' => '</>',
    ));
    }
    
    if (function_exists('add_theme_support')) {
    
    	add_theme_support('post-formats', array('link', 'quote', 'gallery'));
    
    	add_theme_support('post-thumbnails', array('post'));
    
    }
    
    $wp_filetype = wp_check_filetype(basename($filename), null );
      $wp_upload_dir = wp_upload_dir();
      $attachment = array(
         'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
         'post_mime_type' => $wp_filetype['type'],
         'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
         'post_content' => '',
         'post_status' => 'inherit'
      );
      $attach_id = wp_insert_attachment( $attachment, $filename, 37 );
      // you must first include the image.php file
      // for the function wp_generate_attachment_metadata() to work
      require_once(ABSPATH . 'wp-admin/includes/image.php');
      $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
      wp_update_attachment_metadata( $attach_id, $attach_data );
      add_post_meta($post_id, '_thumbnail_id', $attach_id); 
    
    function plum_comments($comment, $args, $depth){
    	$GLOBALS ['comment'] = $comment;
    
    	if (get_comment_type() == 'pingback' || get_comment_type() == 'trackback') : ?>
    
          <li class="pingback" id="comment-<?php comment_ID();?>">
    <article <?php comment_class();?> >
    <header class="borderline">
      <h3 class="commenter"><?php __e('Pingback:', 'PLUM_THEME-framework'); ?></h3>
    <p><?php edit_comment_link();?></p>
      </header>
     <p>   <?php comment_author_link();?> </p>
    
     </article>
    </li>
    
        <?php elseif (get_comment_type() == 'comment') : ?>
    
    <li id= "comment-<?php comment_ID(); ?>">
    <article <?php comment_class('clearfix'); ?> >
    <header class="borderline">
     <h3 class="commenter"> <?php comment_author_link();?> </h3>
    <p><span>on <?php comment_date();?> at <?php comment_time();?></span> <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?></p>
    </header>
    
    <figure class="comments-avatar">
    
     <?php
    
    $avatar_size = 80;
    if ($comment->comment_parent !=0){
    $avatar_size = 64;
    }
    
    echo get_avatar($comment, $avatar_size);
    ?>
    
     </figure>
    
    <?php if($comment->comment_approved == '0') :?>
    <p class="awaiting-moderation"><?php __e('Your comment is awaiting moderation.', 'PLUM_THEME-framework');?> </p>
    
    <?php endif; ?>
    
    <?php comment_text();?>
    
     </article>
    
    <?php endif;
    
    }
    
    ?>
  • The topic ‘pingbacks trackbacks in function php’ is closed to new replies.