Categories and specific style / wp-title
-
Hello! I start this thread to make two questions regarding WordPress 4.3. I’m trying to make a function to assign a specific post-style for each category and also display the first post in a different way. So, on the index.php page I put this code:
<?php if ( have_posts() ) : ?> <?php $post = $posts[0]; $c=0;?> <?php query_posts($query_string . '&cat=1,2'); ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post() ?> <?php $c++; if( $c == 1) :?> <div id="content-news-article-sticky"> <div id="<?php if ( in_category('A') || is_category('A')) { echo 'content-article-A'; } elseif ( in_category('B') || is_category('B')) { echo 'content-article-B'; } elseif ( in_category('C') || is_category('C')) { echo 'content-article-C'; } else { echo 'content-article-A'; } ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <p><?php the_excerpt(); ?></p> <?php else :?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endif;?> <?php endwhile; ?>Assuming A, B, and C are the category slugs, but it didn’t work. The posts get content-article-A style.
Also I’m having some problems with the title of the page. Instead the SITE NAME | DESCRIPTION, the browser shows the site url on the title of the page. I was using wp_title function and now tried with add_theme_support( ‘title-tag’ ); on function.php but it didn’t work.
Thanks in advance! =)
The topic ‘Categories and specific style / wp-title’ is closed to new replies.