Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

[SOLVED] Text only on posts in certain category


  #1  
Old Sep 10, 2011, 11:24 AM
bswb97
 
158 posts · Aug 2010
I've put in some code ABOVE the loop to be conditional for an archive of certain categories. However, this isn't showing up on any individual posts in that category.

Code:

HTML Code:
<?php if (is_category('episodes')) : ?>
<h2>EPISODES:&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=radio">RADIO</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=tv">TV</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=music">MUSIC</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=episodes">ALL</a>&nbsp;&nbsp;&nbsp; </h2>
Here's an example:
http://www.firstpersonmag.com/index_wp.php?p=47

(note the placeholder index file)

That post is categorized as Episodes and sub-category Radio. I've set the conditional code above to also the sub-category of Radio but that little menu doesn't show up.
  #2  
Old Sep 10, 2011, 12:36 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
If you put the code ABOVE the loop, then there is nothing for it to work on. You need it it in the LOOP
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Sep 10, 2011, 02:11 PM
bswb97
 
158 posts · Aug 2010
Ok, I found some PHP code for IN_CATEGORY but it seems to be breaking my code. I'm not sure it depends on placement. Here is the code I'm trying to insert:

HTML Code:
<?php
if ( in_category(‘radio’) )
{
echo ‘Testing Text’;
}
?>
And here it is in context. It's giving me a syntax error:

HTML Code:
<?php /* Post Container starts here */
		if ( function_exists('post_class') ) { ?>
		<div <?php if ( is_page() ) { post_class('post'); } else { post_class(); } ?> id="post-<?php the_ID(); ?>">
		<?php } else { ?>
		<div class="<?php echo ( is_page() ? 'page ' : '' ) . 'post" id="post-'; the_ID(); ?>">
		<?php } ?>


<?php
if ( in_category(‘radio’) )
{
echo ‘Testing Text’;
}
?>



		<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
  #4  
Old Sep 10, 2011, 03:05 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I'll bet you are using a word processor to do the edit. Your code has a right and left single quotes instead of the straight ones. They are different and php is choking on it.

Go to the theme editor and retype the single quotes and update the file
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Sep 10, 2011, 05:59 PM
bswb97
 
158 posts · Aug 2010
That did the trick. However, it's produced another issue. What I need is this:

-Show text at top of category archive
-Show same text at top of each post within a category

I have two sets of code:

-To put it at the top of the category archive, this is above the loop:

HTML Code:
<?php elseif (is_category('radio')) : ?>
<h2>EPISODES:&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=radio">RADIO</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=tv">TV</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=music">MUSIC</a>&nbsp;&nbsp;&nbsp;<a href="http://www.firstpersonmag.com/?category_name=episodes">ALL</a>&nbsp;&nbsp;&nbsp; </h2>
-And this is in the loop to show for a post within a category:

HTML Code:
<?php
if ( in_category('radio') )
{
echo '<h2>EPISODES:***<a href="http://www.firstpersonmag.com/?category_name=radio">RADIO</a>***<a href="http://www.firstpersonmag.com/?category_name=tv">TV</a>***<a href="http://www.firstpersonmag.com/?category_name=music">MUSIC</a>***<a href="http://www.firstpersonmag.com/?category_name=episodes">ALL</a></h2>';
}
?>
This is producing the problem of the category archive grabbing the text twice, once at the very top and once for each post excerpt.

Is there a way to make that second IF statement conditional so that it doesn't show up on the category archive page?
  #6  
Old Sep 10, 2011, 11:22 PM
bswb97
 
158 posts · Aug 2010
Here's a thought -- going on the last post, I can theoretically put it in the Kicker for Single Post Pages. Is there a way to make the Kicker appear conditionally by category? It's not used anywhere else, so maybe I could call the Kicker only in those categories?
  #7  
Old Sep 10, 2011, 11:50 PM
bswb97
 
158 posts · Aug 2010
Answered my own question. With a little bit of experimenting, this worked:

HTML Code:
<?php if (in_category('radio')) { bfa_post_kicker('<div class="post-kicker">','</div>'); } ?>
I seem to be answering my own questions these days, I shouldn't be so hasty to post!

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid "/category/" showing up when pulling posts from a category? night888 Center area post/pages 1 Mar 16, 2011 11:24 AM
Static text/banner image before posts in "posts page" verbalicious Page & Category Menu Bars 14 Nov 12, 2010 05:27 AM
Category menu to show the category posts in the dropdown gjchandler Page & Category Menu Bars 5 Aug 16, 2009 04:42 AM
Colour of text title in sidebar category posts widget jasonblewis Sidebars & Widgets 2 Jul 29, 2009 07:43 PM
Add text in Category Bar bg74blogger Page & Category Menu Bars 1 Apr 19, 2009 07:29 AM


All times are GMT -6. The time now is 05:35 AM.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.