Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Post-Kicker, -Byline & -Footer (http://forum.bytesforall.com/forumdisplay.php?f=17)
-   -   %category-linked% bug? It don't display the first assigned category for a post. (http://forum.bytesforall.com/showthread.php?t=6523)

conon Mar 30, 2010 03:57 AM

%category-linked% bug? It don't display the first assigned category for a post.
 
There seem to be problem with %category-linked% or %category%. It don't display the first category a post belongs to as it should for me.

I would like to display 1 category in the Byline and I need it to be the first category assigned to the post or alternatively exclude a specific category to be shown in the byline.

I use a 'Featured' Category that I assign to posts that I want to feature in Dynamic Content Gallery but I don't want the featured category to be displayed in the Byline. It should display the other Category (News, Post etc) that a post belongs to instead.

I have tried with this code in bfa_postinfo.php without luck:
PHP Code:

// 1st category, linked
    
if ( strpos($postinfo_string,'%category-linked%') !== FALSE ) {
        
$all_categories get_the_category(); 
        
//Default to first category
       
$categoryIndex 0;
       
       
//If first category is "Featured", select second category
       
if ($all_categories[$categoryIndex] == 10)
           
$categoryIndex 1;
        
$category $all_categories[$categoryIndex]->cat_name;
        
$category_linked '<a href="' get_category_link($all_categories[$categoryIndex]->cat_ID) .
        
'">' $category '</a>';
        
$postinfo str_replace("%category-linked%"$category_linked$postinfo);
    } 

I would appreciate any hint or help :)

Thanks

I use Atahualpa 3.4.6
Link to site: http://bit.ly/aTa8yB

juggledad Mar 30, 2010 04:37 AM

can you gie some more detail.
Please list an example of a post and all it's categories and the category that is showing up.

try this, add '%categories(', ')%' to the kicker and
add '%category-linked%' to the byline
the first category listed in the kicker should be in the byline.

categories list in alphabetical order

conon Mar 30, 2010 04:59 AM

Thanks Juggledad.

I have three categories: News, Blog, Featured. All posts got the categories News or Blog before they got assigned to the Featured Category. I tried your suggestion with listing all categories for a post and Featured was listed as the first Category for all posts that also got the 'News' category, but not for the 'Blog' category.

Anyway. I friend helped me with a workaround code below so it excludes my Feature category. So I'm happy now but it still doesn't work as it should do for me with the %category-linked%.

I have no idea if this might have something to do with that I have imported posts, pages, categories etc from an old installation.

Thanks!

PHP Code:

// 1st category, linked
   
if ( strpos($postinfo_string,'%category-linked%') !== FALSE ) {
       
$all_categories get_the_category(); 
       
//Default to first category
      
$categoryIndex 0;
      
      
//If first category is "Featured", select second category
      
if ($all_categories[$categoryIndex]->cat_ID == 10)

          
$categoryIndex 1;
$category $all_categories[$categoryIndex]->cat_name;
       
$category_linked '<a href="' get_category_link($all_categories[$categoryIndex]->cat_ID) .
       
'">' $category '</a>';
       
$postinfo str_replace("%category-linked%"$category_linked$postinfo); 



All times are GMT -6. The time now is 05:46 PM.

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