• Resolved DuncanS

    (@duncans)


    Firstly, thanks for creating such a great plugin. It’s exactly what I needed & I can’t believe more people don’t use it.

    Just one thing – when a post has multiple categories assigned to it, the category key only seems to show it in the first category registered to it. Is there any way around this so that the same post shows up for more than one category when using the category key?

    Thanks!

    http://wordpress.org/plugins/post-tiles/

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’ve found the solution. In the file post-tiles.php you have to change this code (more or less line 539)

    $category = get_the_category();
    	      $category_name = $category[0]->cat_name;
    	      $category_slug = $category[0]->slug;
    
    	      // Recovering Saved Color Values
    	      // Define the Settings for recording
    	      $cat_var = "cat_".$category_slug;

    into this

    $category_name = $category[0]->name;
    	      $category_slug = $category[0]->slug;
    	      $category_name1 = $category[1]->name;
    	      $category_slug1 = $category[1]->slug;
    	      $category_name2 = $category[2]->name;
    	      $category_slug2 = $category[2]->slug;
    
    	      // Recovering Saved Color Values
    	      // Define the Settings for recording
    	      $cat_var = "cat_".$category_slug;
    	      $cat_var1 = "cat_".$category_slug1;
    	      $cat_var2 = "cat_".$category_slug2;

    Then you have to change this (more or less line 575)

    $featured_style = "style='background-image: url(".$url."); background-size: contain;' class='featured-image ".$animation_style." ".$cat_var."'";
    		      } else {
    				  $featured_style = "class='".$cat_var."'";
    			  }

    into this

    $featured_style = "style='background-image: url(".$url."); background-size: contain;' class='featured-image ".$animation_style." ".$cat_var." ".$cat_var1." ".$cat_var2." '";
    		      } else {
    				  $featured_style = "class='"".$cat_var." ".$cat_var1." ".$cat_var2."'";
    			  }

    The line numbers could be different because I’ve made a lot of changes. In this way you could add up to three categories.

    Thread Starter DuncanS

    (@duncans)

    Hi jeegrobot

    Thanks very much for sharing your work on this – I really appreciate it. A couple of things – in the second section when you write $featured_style = “class='”” – do you mean $featured_style = “class='” (ie without the second quotation mark)? My site crashed when I copied and pasted your code. When I removed the 2nd quotation mark, the site worked, but then my thumbnail sizes were distorted… Any thoughts?

    Thanks very much

    Duncan

    Ops sorry, I made a mistake. Leave the whole part after } else { like it is originally and it works.

    You can see it working here http://www.mambotango.eu/demo/mesh/meshers-list where people have three different custom taxonomies: Industry (IT, etc.) Company (AdProfit, Mesh, etc.) and the last one that is empty for the moment.

    Thread Starter DuncanS

    (@duncans)

    Hi jeegrobot

    Thanks for the update. I’ve made the changes you suggested & it’s not working for me at all. Now even the single category posts aren’t being highlighted when I click on a category…

    Thanks for the suggestions though.

    Duncan

    Thread Starter DuncanS

    (@duncans)

    Hi again jeegrobot

    I’ve found what the problem is. You need to make sure that the line “$category = get_the_category();” is *not removed* – then everything works. Great!

    Thanks again

    Duncan

    Hi Duncan,

    sorry for having done a little mess. Yesterday I was a little tired and I copied the code in a wrong way. I noticed it only now by reviewing your post.

    In line 539 (more or less) change this

    $category = get_the_category();
    	      $category_name = $category[0]->cat_name;
    	      $category_slug = $category[0]->slug;
    
    	      // Recovering Saved Color Values
    	      // Define the Settings for recording
    	      $cat_var = "cat_".$category_slug;

    to this

    $category = get_the_category();
                  $category_name = $category[0]->name;
    	      $category_slug = $category[0]->slug;
    	      $category_name1 = $category[1]->name;
    	      $category_slug1 = $category[1]->slug;
    	      $category_name2 = $category[2]->name;
    	      $category_slug2 = $category[2]->slug;
    
    	      // Recovering Saved Color Values
    	      // Define the Settings for recording
    	      $cat_var = "cat_".$category_slug;
    	      $cat_var1 = "cat_".$category_slug1;
    	      $cat_var2 = "cat_".$category_slug2;

    In my previous post the first line was missing.

    Then, on line 575

    $featured_style = "style='background-image: url(".$url."); background-size: contain;' class='featured-image ".$animation_style." ".$cat_var."'";

    into this

    $featured_style = "style='background-image: url(".$url."); background-size: contain;' class='featured-image ".$animation_style." ".$cat_var." ".$cat_var1." ".$cat_var2." '";

    Sorry for the mistakes. This should work.

    Thread Starter DuncanS

    (@duncans)

    Great – thanks. All working perfectly now – you can see it in action on the recent work section of my site.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Posts with multiple categories’ is closed to new replies.