• Good day all;

    I am working on a custom theme for my organization and have two issues with categories. These issues do not happen with the default theme, but seem to happen with my theme and I cannot figure out why as most of the code is exactly the same, I just wrapped a new header/footer around it and some custom php/sql code to pull the authors bio and photo from another database.

    Issue #1:
    If you visit this page : https://www.tdslaw.com/blogs/jeff_pniowsky/ you will notice that 3 out of the 4 posts show up as uncategorized, only the newest post has a category. All 4 posts are in categories.

    My index.php code:

    <div id="bioSection">
    	<div class="spacer">&nbsp;</div>
    		<img class="authorPhoto" src="<?php echo $photoPath;?>" title="Photo of <?php bloginfo('name'); ?>" alt="Photo of <?php bloginfo('name'); ?>"/>
    		<p class="bio"><?php echo $intro; ?></p>
    	<div class="spacer">&nbsp;</div>
    </div>
    
    <div id="recentPosts">
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="postContainer" id="post-<?php the_ID(); ?>">
    				<div class="postTitleContainer"><h2 class="postTitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
    
    				<div class="postContent">
    					<font face="helvetica" size="2" color="#445261" style="color:#445261;font-size:11px;font-family:'Trebuchet MS',helvetica;">
    					<?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    <p><a href="<?php the_permalink() ?>" style="text-decoration:underline;color:#445261;" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Click here to read the rest of this post.</a>
    					</font>
    				</div>
    
    				<p class="postmetadata"><font face="helvetica" size="2" color="#445261" style="color:#445261;font-size:11px;font-family:'Trebuchet MS',helvetica;"> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></font></p>
    			</div>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Issue #2:
    On the same page, if you look on the right side you will see it says No Categories even though I have 4.

    In my sidebar.php file I have the following code:

    <div id="sideBarContainer">
    	<div id="sidebar">
    		<h3 class="sideBarTitle">Categories</h3>
    		<ul id="categoryList">
    		<?php wp_list_categories(); ?>
    		</ul> 
    
    	</div>
    </div>

    But if you navigate in to an actual category such as https://www.tdslaw.com/blogs/jeff_pniowsky/category/cat2/cat2-sub1/ you can see all the categories fine.

    Can anyone provide some insight as to why this is happening?

Viewing 9 replies - 1 through 9 (of 9 total)
  • How is $intro being populated? It sounds to me as if you have other Loops on these pages that you haven’t mentioned. The code for index.php is obviously incomplete, for a start. However, please use the WordPress pastebin for larger blocks of code and post the pastebin url(s) here.

    Thread Starter ironicsky

    (@ironicsky)

    Here is the link to the full index.php

    https://wordpress.pastebin.ca/1790608

    The information is being called from another database prior to the main loop

    Just noticed that the older posts on https://www.tdslaw.com/blogs/jeff_pniowsky/ all have malformed permalinks. Not sure if that’s part of your root problem but it could well be a factor.

    Thread Starter ironicsky

    (@ironicsky)

    Thats part of the problem esmi, the perma-links for posts 2-4 do not generate properly, only the first one does.

    I’ve attached my header.php as well in case it is of interest

    https://wordpress.pastebin.ca/1790616

    in my header I had get_permalink() for some reason. When I removed it, the first item now shows with a broken perma links

    There’s nothing in your header.php that should cause a problem – although you really should have a proper DOCTYPE instead of just <html>.

    Looks like you have bigger problems at the moment though. The site is down – “Unable to select database”.

    Thread Starter ironicsky

    (@ironicsky)

    Its back up now ??
    I was hacking around with some of the code.

    I’ve been line by line debugging my code, and for whatever reason when I open the new SQL connection it causes issues. If I comment out my SQL commands wordpress pulls the site categories properly

    Thread Starter ironicsky

    (@ironicsky)

    I got it…

    I changed
    mysql_connect("XXXXXX","XXXXX","XXXXX");

    to
    mysql_connect("XXXXXX","XXXXX","XXXXX",TRUE);

    Apparently if you don’t do TRUE, PHP screws with any existing MySQL connection to do what it needs. Putting TRUE forces it to create a new session.

    Thread Starter ironicsky

    (@ironicsky)

    Thanks for the help ??

    Glad you got that sorted. Do you still have the permalink/category problem or did forcing the new MySQL session fix it?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘2 Different Category Issues’ is closed to new replies.