Need Wordpress Category Description Code Help

13 replies
What is the necessary code to have the wordpress category page description only on one page and not all of them thus creating duplicate content?

For instance, my description is one page 1, 2, 3, etc.

What code only designates this to the first page? Would that code be altered on the archive.php page?
#category #code #description #wordpress
  • Profile picture of the author mlab
    What theme are you using? That could affect the display behavior.

    Yes, archive.php is the correct file

    Unless you have very little other content - I don't think small amounts of duplicate content will affect your site rankings - though I am curious why the category description shows up on so many pages. How have you set those pages..and what content is on those pages?
    {{ DiscussionBoard.errors[6706309].message }}
    • Profile picture of the author wiseworks
      Originally Posted by mlab View Post

      What theme are you using? That could affect the display behavior.

      Yes, archive.php is the correct file

      Unless you have very little other content - I don't think small amounts of duplicate content will affect your site rankings - though I am curious why the category description shows up on so many pages. How have you set those pages..and what content is on those pages?
      I paid someone to do a custom theme a few years back.

      The reason I brought up duplicate content is because in google webmaster tools they are counting just that one category as 15 duplicate pages since I have so many posts in that one category.

      It's also counting my other categories as duplicate content too.

      I see this code in the archive.php file but I don't know why it would put the description on every single page within a category.

      <?php echo category_description(); ?>

      I'm not sure what you mean by how have I set those pages.

      I have four categories I blog about and place the content in at least one of those categories.

      I don't really see anything within my wordpress panel that allows me to set anything for categories except for where you can add new ones and edit existing ones.
      {{ DiscussionBoard.errors[6706427].message }}
      • Profile picture of the author rhinocl
        I'm guessing if you go to your posts|categories page in the dashboard (where you add new categories, define their stub and parents) and go up top to the display drop down box you will be able to display category definitions. Check that each category has a unique definition. This may not be the whole solution but without looking at your site I'm just guessing.
        {{ DiscussionBoard.errors[6711274].message }}
        • Profile picture of the author wiseworks
          Originally Posted by rhinocl View Post

          I'm guessing if you go to your posts|categories page in the dashboard (where you add new categories, define their stub and parents) and go up top to the display drop down box you will be able to display category definitions. Check that each category has a unique definition. This may not be the whole solution but without looking at your site I'm just guessing.
          I don't see anything like a display drop down box to display category definitions.

          The only thing in edit categories is name, slug, parent and description.
          {{ DiscussionBoard.errors[6721854].message }}
          • Profile picture of the author rhinocl
            Seeing as that php line you quoted earlier is there, I think the option to add them is supported by your theme and you've just missed it somehow.
            To double check, switch to the default theme and update it to the latest version. If you find it there but not in your custom theme then you may have to have your theme modified to get that option.
            {{ DiscussionBoard.errors[6723574].message }}
          • Profile picture of the author rhinocl
            Originally Posted by wiseworks View Post

            I don't see anything like a display drop down box to display category definitions.

            The only thing in edit categories is name, slug, parent and description.
            Just re-read this 'definitions' was my typo should have read 'descriptions'. If you have a different one for each category I'm assuming you cut down on the duplicate content problem? Then to get rid of the 15 pages in the same category you can increase the number of post per category 'page' and cut down on the size of the excerpts.

            That won't work for some sites so then your choice is to find the id for the category page and add an if statement into the template that hides the description section unless you are on category1id=[yourfirstcategortpage] for example.
            {{ DiscussionBoard.errors[6728103].message }}
            • Profile picture of the author wiseworks
              Originally Posted by rhinocl View Post

              Just re-read this 'definitions' was my typo should have read 'descriptions'. If you have a different one for each category I'm assuming you cut down on the duplicate content problem? Then to get rid of the 15 pages in the same category you can increase the number of post per category 'page' and cut down on the size of the excerpts.

              That won't work for some sites so then your choice is to find the id for the category page and add an if statement into the template that hides the description section unless you are on category1id=[yourfirstcategortpage] for example.
              Thank you very much for your help!

              I'm not a developer so is there anyone who can help with this one piece of code?

              What code do I place in my archive.php file to only display the category description on the first page of posts for the category?
              {{ DiscussionBoard.errors[6745257].message }}
              • Profile picture of the author Brennen Noble
                You probably need to actually modify what is already there, not just add to it. Using an IF statement you'll need to wrap the code that displays it inside the statement. Can you post the archive.php file somewhere that we can see it?
                Signature
                Over 2400 Warriors Use SoreThumb On Their Sites, Do You?
                {{ DiscussionBoard.errors[6745302].message }}
                • Profile picture of the author wiseworks
                  Originally Posted by Brennen Noble View Post

                  You probably need to actually modify what is already there, not just add to it. Using an IF statement you'll need to wrap the code that displays it inside the statement. Can you post the archive.php file somewhere that we can see it?
                  Here is the code. I hope it's okay I display it here.

                  <?php get_header(); ?>

                  <!--include sidebar-->
                  <?php include(TEMPLATEPATH."/sidebar.php");?>

                  <div id="content">
                  <!--the loop-->

                  <?php if (have_posts()) : ?>

                  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
                  <?php /* If this is a category archive */ if (is_category()) { ?>
                  <h3><?php echo single_cat_title(); ?></h3>

                  <?php echo category_description(); ?>

                  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
                  <h3>Archive for <?php the_time('F jS, Y'); ?></h3>

                  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
                  <h3>Archive for <?php the_time('F, Y'); ?></h3>

                  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
                  <h3>Archive for <?php the_time('Y'); ?></h3>

                  <?php /* If this is a search */ } elseif (is_search()) { ?>
                  <h3>Search Results</h3>

                  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
                  Author Archive

                  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
                  Blog Archives

                  <!--do not delete-->
                  <?php } ?>


                  <!-- navigation-->

                  <?php next_posts_link('&laquo; Previous Entries') ?>
                  <?php previous_posts_link('Next Entries &raquo;') ?>

                  <!--loop article begin-->

                  <?php while (have_posts()) : the_post(); ?>
                  <!--post title as a link-->
                  <div class="postspace3">
                  </div>
                  <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                  <!--post time-->
                  <b><?php the_time('l, F jS, Y') ?></b>

                  <!--optional excerpt or automatic excerpt of the post-->
                  <?php the_excerpt(); ?>


                  <!--one post end-->
                  <?php endwhile; ?>

                  <!-- navigation-->
                  <?php next_posts_link('&laquo; Previous Entries') ?>
                  <?php previous_posts_link('Next Entries &raquo;') ?>
                  <!-- do not delete-->
                  <?php else : ?>

                  Not Found
                  <?php include (TEMPLATEPATH . '/searchform.php'); ?>

                  <!--do not delete-->
                  <?php endif; ?>


                  <!--archive.php end-->
                  </div>

                  <!--include footer-->
                  <?php get_footer(); ?>
                  {{ DiscussionBoard.errors[6747296].message }}
  • Profile picture of the author locke815
    Check out some plugins that gives you the proper archiving functions.
    {{ DiscussionBoard.errors[6747044].message }}
  • Profile picture of the author brianng
    That's right.
    It rewards reading into database schema of wordpress before you mess it up =) Database Description « WordPress Codex
    {{ DiscussionBoard.errors[6747459].message }}
  • Profile picture of the author Brennen Noble
    Change

    echo category_description();

    to

    <?php if ($paged < 2 ) {
    echo category_description();
    } ?>

    That should work
    Signature
    Over 2400 Warriors Use SoreThumb On Their Sites, Do You?
    {{ DiscussionBoard.errors[6750103].message }}

Trending Topics