WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Category archive separation (1 post)

  1. jcc5018
    Member
    Posted 1 year ago #

    I am working on rebuilding my html coded site into a wordpress site but I am having a few issues with a theme. I am using prestige theme for a portfolio site.

    I have a lot of written articles that I decided to include as post instead of creating individual pages. I set up a category structure like this
    Writing
    -Articles
    --Business
    --Christianity
    --Relationships
    -Reports
    -Poetry

    ect.

    so for each post I set the bottom most category that fits with the post which is fine, but when I add a category link to my writing category, it displays all post without any sort of separation.

    This is where the issue is. How do I separate the post into their respective categories. Each Category would be a section header with its respective post beneath.

    I have tried to do this a few different ways. First just linking to the category page and trying to figure out the php code needed to make the change (with no luck)

    And two, just creating a page and using a List category posts plugin to create the separation. The second method would work expect I would like it to display the same information as the category page template would. Name, post date, comment box, and custom description.

    I can add most of that date but it doesnt format well and the excerpt it uses does not use the one from the custom field included on the post page. In other words, I do not just want it to grad the first 50 words or whatever, I want to include my own summary. The archive page does this, but not the plugin.

    So, if anyone could help me figure out what I need to change this would be great. I am also wondering how to display a sidebar for the archive page. Having a default sidebar option isn't going to work because I want to have two sets of links for two different post groups.

    Here is the category template page from the theme that I think is needed.

    <p>Category: <?php single_cat_title(); ?></p><?php
    /**********************************************************************
    * PRESTIGE WORDPRESS EDITION
    * (Ideal For Business And Personal Use: Portfolio or Blog)
    *
    * File name:
    *      category.php
    * Brief:
    *      Theme single category page code
    * Author:
    *      DigitalCavalry
    * Author URI:
    *      http://themeforest.net/user/DigitalCavalry
    * Contact:
    *      digitalcavalry@gmail.com
    ***********************************************************************/ 
    
        get_header();
        the_post();
    
        global $post;
        global $more;    // Declare global $more (before the loop).
        global $wp_query;
    
        $pageid = $post->ID;
        $categoryid = (get_query_var('cat')) ? get_query_var('cat') : '';
        $category = get_category($categoryid);
    
        $dccp = GetDCCPInterface();     
    
    ?>
    
        <div class="navigation-tree-container">
            <?php dcf_naviTree($post->ID, 0, $category->name); ?>
        </div>
    
        <div id="content">
    
            <?php
                $dccp->getIGeneral()->includeSidebar($pageid);
                if($dccp->getIGeneral()->getSidebarOnRight())
                {
                    echo '<div class="page-width-600-left">';
                } else
                {
                   echo '<div class="page-width-600">';
                }
    
                echo '<h1>'.$category->name.'</h1>';
    
                echo '<div style="margin-bottom:25px;">'.do_shortcode($category->description).'</div>'; 
    
                $excluded = $dccp->getIGeneral()->getExcludedCategories();
                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $args=array('paged'=>$paged,'cat'=>$categoryid);
                if($excluded != '') { $args['category__not_in'] = $excluded; }            
    
                query_posts($args);
                $max_page = $wp_query->max_num_pages;                                                                  
    
                if(have_posts())
                {
                    while(have_posts())
                    {
                        the_post();
                        $imagepath = get_post_meta($post->ID, 'post_image', true);
                        $postdesc = get_post_meta($post->ID, 'post_desc', true);
                        $imagedesc = get_post_meta($post->ID, 'post_image_desc', true);
                        $videopath = get_post_meta($post->ID, 'post_video', true);
                        $disablevideo = get_post_meta($post->ID, 'post_disable_video', true);
                        $novoting = get_post_meta($post->ID, 'post_novoting', true);
                        $more = 0;
    
                        $month = get_the_time('n', $post->ID);
                        $year = get_the_time('Y', $post->ID);
    
                        $out = '';
                        $out .= '<div class="blog-post">';   
    
                            if($videopath != '' and $disablevideo == '')
                            {
                                $out .= '<div class="photo">'.do_shortcode($videopath).' '.$imagedesc.'</div>';
                            } else
                            if($imagepath != '')
                            {
                                $out .= '<div class="photo"><a class="async-img image" href="'.get_permalink($post->ID).'" rel="'.$imagepath.'" ></a>'.$imagedesc.'</div>';
                            } else
                            {
                                $out .= '<div class="no-photo-spliter"></div>';
                            }                                      
    
                            $out .= '<div class="post-content">';
    
                            if('open' == $post->comment_status)
                            {
                                $out .= '<a href="'.get_comments_link($post->ID).'" class="comments">'.get_comments_number($post->ID).'</a>';
                            } 
    
                            $out .= '<div class="info">
                                    <a class="date-left"></a><a href="'.get_month_link($year, $month).'" class="date">'.get_the_time('F j, Y').'</a><a class="date-right"></a>
                                    Posted by&nbsp;<a href="'.get_author_posts_url($post->post_author).'" class="author">'.get_the_author_meta('nickname', $post->post_author).'</a> in ';
    
                                    $catlist = wp_get_post_categories($post->ID);
                                    $count = count($catlist);
                                    for($i = 0; $i < $count; $i++)
                                    {
                                        if($i > 0)
                                        {
                                           $out .= ', ';
                                        }
                                        $cat = get_category($catlist[$i]);
                                        $out .= '<a href="'.get_category_link($catlist[$i]).'" >'.$cat->name.'</a>';
    
                                    }                                
    
                                $out .= '</div>';
    
                                $out .= '<a href="'.get_permalink($post->ID).'"><h2>'.$post->post_title.'</h2></a>';
                                echo $out;
    
                                if($postdesc != '')
                                {
                                    $out = '';
                                    $out .= apply_filters('the_content', $postdesc);
                                    $out .= ' <a href="'.get_permalink($post->ID).'">Read&nbsp;more</a>';
                                    echo $out;
                                } else
                                {
                                    the_content('Read&nbsp;more');
                                }
    
                            $out = '';
                            $out .= '<div class="blog-post-bottom-wrapper">';
                            $blog_pages_voting = GetDCCPInterface()->getIGeneral()->showBlogPagesVoting();
                            if(GetDCCPInterface()->getIGeneral()->showPostVoting() and $novoting == '' and $blog_pages_voting)
                            {
                                global $dcp_votingshortcodes;
                                if(isset($dcp_votingshortcodes))
                                {
                                    $out .= $dcp_votingshortcodes->votePostStarsCreate($post->ID, GetDCCPInterface()->getIGeneral()->showVotingGlypsNum(), 'left', $post->post_type);
                                }
                            }                         
    
                           // post tags list
                           $posttags = get_the_tags();
                           $count = 0;
                           if($posttags !== false)
                           {
                                $count = count($posttags);
                           }
    
                           if($count > 0)
                           {
                               $out .= '<div class="blog-post-tags">
                                        <span class="name">Tags:</span> ';
    
                               $i = 0;
                               foreach($posttags as $tag)
                               {
                                   if($i > 0)
                                   {
                                       $out .= ',&nbsp;';
                                   }
                                   $title = '';
                                   if($tag->count == 1) { $title = 'One post'; } else { $title = $tag->count.' posts'; }                                
    
                                   $out .= '<a href="'.get_tag_link($tag->term_id).'" class="tag link-tip-bottom" title="'.$title.'">'.$tag->name.'</a>';
                                   $i++;
                               }
                               $out .= '</div>';                                            
    
                           } else
                           {
                                if(GetDCCPInterface()->getIGeneral()->showNoTags())
                                {
                                   $out .= '<div class="blog-post-tags">
                                            There are no tags associated with this post.
                                        </div>';
                                }
                           } 
    
                            $out .= '<div class="clear-both"></div></div>';
                            $out .= '</div> <!-- content -->
                        </div> <!-- blog-post -->';
                        echo $out;
    
                    } // while
                } else
                {
                    echo '<p>There are no posts in this category.</p>';
                }   
    
                GetDCCPInterface()->getIGeneral()->renderSitePagination($paged, $max_page);             
    
            ?>
            </div>  <!-- page-width-xx0 -->
            <div class="clear-both"></div>
        </div> <!-- content -->
    
    <?php
        get_footer();
    ?>

    Here is the current archive arrangement which I like if I can divide it by category and add my portfolio sidebar. http://jonccody.com/fun/blog/category/writing/

    This is the page version with plugins that does not use the same styling that the template version did http://jonccody.com/fun/blog/portfolio/writing/

    Please let me know if you need any additional files, thanks for any help you can provide.

Topic Closed

This topic has been closed to new replies.

About this Topic