I am trying to style this category different to how all the other categories appear. I have added 1 post to the category 'News' to test and style accordingly. The problem i have is that this post is not appearing on the page and i am now lost as to where i am with it. I dont want to get too confused so thought i would ask for help.
Please let me know if you need the login information or what files you need to see?
Many thanks,
Andrew
WordPressPHPWeb Languages and StandardsWeb Development
Last Comment
Andy6350
8/22/2022 - Mon
Jason C. Levine
What did you change to style it differently?
Andy6350
ASKER
In the header-search.ph file which is used on the categories, i put the following code:
<?php if (is_category('news') ):
       // category latest-news ?>
 Â
      <style type="text/css">
     Â
      #main {
          Â
           background-image:url(/wp-content/themes/localestateagent/images/news-bg.jpg);           Â
}
#cat-content {
      width:434px;
      float:left;
      margin:0px;
}
#container {
      width:434px;
      float:left;
      margin:0px;
     Â
}
.entry-content, .entry-summary {
      width:100%;
}
      </style>
 Â
<?php endif; // end the if, no images for other other categories ?>
yes, I have attached a jpg of the result i am after. I want all the posts in the category 'news' to display like the attached image. The rest of the categories to stay the same. latestnews.jpg
Jason C. Levine
No, I understand what your desired end result is. Â I'm trying to determine how you got a wordpress post to end up with the .html extension and outside of the normal taxonomy.
I changed the permalink and it said that the page could not be found. so i have changed it back. I dont understand why the post isn't listing, because all i changed was the styling. I am a bit nervous about updating any plugins as i am concerned they will conflict.
Post News 1 should be appearing in that news category :/
Jason C. Levine
>> I am a bit nervous about updating any plugins as i am concerned they will conflict.
See, I think you have a plugin already in conflict with something and that's why the category page isn't working properly.
The reason i didn't think it was a conflict, was because it has been working fine until now, i havent added anything.
The slug does say 'news'
Jason C. Levine
Can you paste the theme's category.php here?
Andy6350
ASKER
<?php
/**
 * The template for displaying Category Archive pages.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?>
<?php include (TEMPLATEPATH . '/header-search.php'); ?>
<div class="slogan-strip">
    <div id="search" class="widget-container widget_search">
    Â
    Â
     Â
      <?php get_search_form(); ?>
 Â
Â
Â
    </div>
</div>
<?php if (is_category('news')) { ?>
                                                  <?php include (TEMPLATEPATH . '/sidebar-news.php'); ?>
                 Â
                   <?php } ?>
           <div id="container">
                 <div id="cat-content" role="main">
                      <h1 class="widget-title">
                     Â
       Â
                     Â
                      <?php
$category = get_the_category();
$parent = get_cat_name($category[0]->category_parent);
echo $parent;
?>
                      <?php
                            printf( __( '%s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );
                      ?></h1>
       Â
       Â
       Â
       Â
       Â
       Â
       Â
                      <?php
                            $category_description = category_description();
                            if ( ! empty( $category_description ) )
                                 echo '<div class="archive-meta">' . $category_description . '</div>';
                      /* Run the loop for the category page to output the posts.
                       * If you want to overload this in a child theme then include a file
                       * called loop-category.php and that will be used instead.
                       */
                      get_template_part( 'loop', 'category' );
                      ?>
                 </div><!-- #content -->
           </div><!-- #container -->
Also, have you tried switching to a new theme for testing and also disabling plugins?
Andy6350
ASKER
<?php
/**
 * The loop that displays posts.
 *
 * The loop displays the posts and the post content.  See
 * http://codex.wordpress.org/The_Loop to understand it and
 * http://codex.wordpress.org/Template_Tags to understand
 * the tags used in it.
 *
 * This can be overridden in child themes with loop.php or
 * loop-template.php, where 'template' is the loop context
 * requested by a template. For example, loop-index.php would
 * be used if it exists and we ask for the loop with:
 * <code>get_template_part( 'loop', 'index' );</code>
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?>
<?php if (in_category('testimonials')) { ?>
                                                  <div class="testimonial-intro">
                 Â
                                                       <p>
                                                       Find out below how much our clients saved and what they had to say about it. Click on the properties below for more details, testimonials and fee savings.
                    </p>
                  </div>
                 Â
                  <div class="testimonial-bottom"></div>
                 Â
                   <?php } ?>
 Â
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages >Â 1 ) : ?>
      <div id="nav-above" class="navigation">
  <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
           <?php /*?><div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Previous Properties', 'twentyten' ) ); ?></div>
           <div class="nav-next"><?php previous_posts_link( __( 'More Properties <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div><?php */?>
      </div><!-- #nav-above -->
<?php endif; ?>
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() &&Â ! is_category('25') Â ) : ?>
      <div id="post-0" class="post error404 not-found">
           <h1 class="entry-title"><?php _e( 'No properties available', 'twentyten' ); ?></h1>
           <div class="entry-content">
                 <p><?php _e( 'Apologies, but we have currently no properties available within this category', 'twentyten' ); ?></p>
                Â
           </div><!-- .entry-content -->
      </div><!-- #post-0 -->
 Â
 Â
<?php endif; ?>
 <?php if (is_category('25') && ! have_posts()) { ?>
      <div id="post-0" class="post error404 not-found">
           <h1 class="entry-title"><?php _e( 'Our testimonials will be coming shortly', 'twentyten' ); ?></h1>
           <div class="entry-content">
                 <p><?php _e( 'Apologies, but we have many testimonials coming soon, thank you for your patience.', 'twentyten' ); ?></p>
                Â
           </div><!-- .entry-content -->
      </div><!-- #post-0 -->
 Â
 Â
<?php } ?>
<?php
      /* Start the Loop.
      *
      * In Twenty Ten we use the same loop in multiple contexts.
      * It is broken into three main parts: when we're displaying
      * posts that are in the gallery category, when we're displaying
      * posts in the asides category, and finally all other posts.
      *
      * Additionally, we sometimes check for whether we are on an
      * archive page, a search page, etc., allowing for small differences
      * in the loop on each template without actually duplicating
      * the rest of the loop that is shared.
      *
      * Without further ado, the loop:
      */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display posts in the Gallery category. */ ?>
     Â
     Â
      <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
           <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                 <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                 <div class="entry-meta">
                      <?php twentyten_posted_on(); ?>
                 </div><!-- .entry-meta -->
                 <div class="entry-content">
<?php if ( post_password_required() ) : ?>
                      <?php the_content(); ?>
<?php else : ?> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
                      <?php
                            $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
                            if ( $images ) :
                                 $total_images = count( $images );
                                 $image = array_shift( $images );
                                 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
                      ?>
                                 <div class="gallery-thumb">
                                       <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
                                 </div><!-- .gallery-thumb -->
                                 <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
                                            'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
                                            $total_images
                                       ); ?></em></p>
                      <?php endif; ?>
                                 <?php the_excerpt(); ?>
<?php endif; ?>
                 </div><!-- .entry-content -->
Â
                 <div class="entry-utility">
                      <a href="<?php echo get_term_link( _x('gallery', 'gallery category slug', 'twentyten'), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
                      <span class="meta-sep">|</span>
                      <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
                      <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
                 </div><!-- .entry-utility -->
    Â
           </div><!-- #post-## -->
   Â
<?php /* How to display all other posts. */ ?>
      <?php else : ?>
 Â
 Â
 Â
 Â
 Â
   <?php if ( is_archive()) : // Only display excerpts for archives and search. ?>
  Â
  Â
  Â
  Â
   <div id="post-<?php the_ID(); ?>" <?php post_class(); ?> >
                   <div id="property-item">
            <div class="thumb">
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
            </div>
                          <div class="innerDivLeft">
         Â
         Â
         Â
                                    <div class="list-header">
                                    <div class="list-location"> Â
                                      <h2><?php if ( get_post_meta($post->ID, 'address line 2', true) ) : ?>
                                      <?php echo get_post_meta($post->ID, 'address line 2', true) ?>
                                      <?php endif; ?></h2>
                                    </div>
                                   Â
                                    <div class="list-price">
                                   Â
                                      <h2><?php if ( get_post_meta($post->ID, 'price', true) ) : ?>
                                      <?php echo get_post_meta($post->ID, 'price', true) ?>
                                      <?php endif; ?></h2>
                                   Â
                                    </div><div class="divClear"></div>  Â
                                    </div><!-- .list-header -->              Â
                                                Â
                                        <h3><?php the_title(); ?></h3>
                                         Â
                                        <div class="property-description-entry-summary">
                                        <?php /*?><?php the_excerpt(); ?><?php */?><?php excerpt('20'); ?>
                                         <div>
         Â
           <?php if ( get_post_meta($post->ID, 'sold', true) ) : ?>
             <div class="sold"><?php echo get_post_meta($post->ID, 'sold', true) ?>
              </div> Â
             <?php else:?>
            Â
            Â
             <?php endif; ?>
         Â
        </div> Â
                                       Â
                                  Â
                                  Â
                                    </div><!-- .entry-summary -->
                                     <div class="divClear"></div>
                                   Â
                                   Â
                                   Â
         </div><!-- .innerDivLeft -->    Â
         <div class="divClear"></div>                     Â
          Â
                   </div><!-- #property-item --> Â
      Â
      Â
       </div>
     Â
       <?php endif; ?>
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
      Â
   <?php if ( is_search()) : // Only display excerpts for archives and search. ?>
   <div id="post-<?php the_ID(); ?>" <?php post_class(); ?> >
   <h2><?php the_title(); ?></h2>
                                   <div class="entry-summary">
                                   <?php the_excerpt(); ?>
                                  Â
                                   </div><!-- .entry-summary -->
 Â
  Â
      Â
      Â
       </div>
       <?php endif; ?>
      Â
       Â
       Â
       Â
                             Â
                             Â
                             Â
                              Â
                  Â
         Â
   Â
  <div class="divClear"></div>
 Â
  Â
           <?php comments_template( '', true ); ?>
      <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
 Â
 Â
<?php endwhile; // End the loop. Whew. ?>
<?php if (is_category('18')) { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 370844</span></h2>
</div>
<?php } elseif (is_category('19')) { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 370844</span></h2>
</div>
<?php } elseif (is_category('20')) { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 370844</span></h2>
</div>
<?php } elseif (is_category('21')) { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 370844</span></h2>
</div>
<?php } elseif (is_category('22')) { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 370844</span></h2>
</div>
<?php } else { ?>
<div class="why-not">
<h2>Why not call us today!</h2>
<h2>Telephone <span style="color:#f172ac;">01480 210222</span></h2>
</div>
Â
<?php } ?>
   Â
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( Â $wp_query->max_num_pages >Â 1 ) : ?>
                      <div id="nav-below" class="navigation">
       Â
        <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
                            <?php /*?><div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Previous Properties', 'twentyten' ) ); ?></div>
                            <div class="nav-next"><?php previous_posts_link( __( 'More Properties <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div><?php */?>
                      </div><!-- #nav-below -->
<?php endif; ?>
Andy6350
ASKER
I didnt really want to switch themes as the site is live
I understand that but we need to determine the cause of the problem. Â Switching themes, albeit briefly, will tell us if the alterations to your theme files are causing the issue or the plugins.
Andy6350
ASKER
I have switched themes but the post is still not appearing?
Jason C. Levine
Alright, now disable ALL plugins and see if the post shows up.
I cant see how this would be a plugin issue? as i can add new posts to the testimonials category.
Thanks,
Andy6350
ASKER
I apologise, yes no new posts are showing up, not even her properties! :/
Andy6350
ASKER
I think i have narrowed the issue down. It seems that it WILL upload posts, but only if they all the custom fields for that post/property have been filled in :/ very odd
<?php if ( get_post_meta($post->ID, 'address line 1', true) ) : ?>
                  <?php echo get_post_meta($post->ID, 'address line 1', true) ?>
                  <?php endif; ?>
Andy6350
ASKER
I thought about only showing the custom fields if they are in a certain category. I tried the following code with no luck:
<?php if (is_category('17,23,25') || cat_is_ancestor_of(17,23,25, $cat)) { ?>
                                                  <?php if ( get_post_meta($post->ID, 'address line 1', true) ) : ?>
                                                  <?php echo get_post_meta($post->ID, 'address line 1', true) ?>
                                                  <?php endif; ?>
                  <?php } ?>
Any Ideas?
Jason C. Levine
>> I cant see how this would be a plugin issue?
Since I have no visibility to how you set up the site or what other alterations you have made or plugins you are using, I'm going through the list of common problems. Â Custom fields shouldn't care if they are filled out or not unless you've also changed something in how the Loop behaves so that only posts with all fields present get pulled. Â This is the first mention of custom fields in the posts so there's a whole other world of issues to examine.
As I'm out of ideas and you seem resistant to trying what I suggest anyway, I'm bowing out here. Â Good luck.