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)
-   -   How to exclude a category from showing in the kicker or footer (http://forum.bytesforall.com/showthread.php?t=22668)

Jerry_Q4d Jul 23, 2014 03:57 AM

How to exclude a category from showing in the kicker or footer
 
Hi, I am back to ask the great experts here! Currently I am using the kicker and footer info items to display the categories for each post. I am using the shortcode %categories-linked for this:

%categories-linked(', ')%

So each category gets a link in the kicker/footer, separated by a colon. Basically, this is what I want. However, there a a few categories I am using solely for technical reasons (images are displayed based on this category by using css and the like). I dont want these "ugly" technical categories to show up in the list of categories displayed by %categories-linked%. Is there a way to do that?

I have tried using css to apply "display: none;" to the category links in question, but it seems they dont have a special id or tag. All I came up with is:

.category-total-mg div.post-footer a:hover, div.post-footer a:link, div.post-footer a:visited, div.post-footer a:active {
display: none;
}

But of course this removes ALL category links in case the category is "total-mg", and not just the specific link to category "total-mg". Hope I am making myself clear...

juggledad Jul 23, 2014 07:35 AM

The answer is no...but

I dug thru the code to see if it could be changed to add a class to the <a> for each category, but the way the theme code is written, we call a wordpress function (the_category) and it returns a list of links to the categories.

Now there are a couple things that could be done.
1) edit the wordpress function to return the category as a class in the <a.....>
2) try coding a plugin to do what (1) would do
3) change the Atahualpa code to get the links differently and add in the class

any of the above might work but if you can't do it yourself, you going to have to pay someone to do the coding.

juggledad Jul 23, 2014 06:35 PM

try this plugin https://wordpress.org/plugins/hide-categories/

Jerry_Q4d Jul 24, 2014 12:22 AM

I think it would be a good solution, but unfortunately I also use my "ugly" categories for google analytics tracking (visits per category etc.). I use the Google Analytics for WordPress plugin by Joost de Valk for this, which uses the same WordPress function. If I hide the categories, I can no longer track them with GA... so this is no solution for me, I am afraid. Any other ideas?

I read somewhere in the BFA forums that you could theoretically insert a widget into the footer, then execute php in it (with a plugin), and so check for the categories.

Or alternatively there is a CSS function called after, which inserts text. If it is possible to insert a link with it, I could use CSS to insert links to categories into the kicker and footer if the post belongs to a certain category... sort of doing it the other way around.

juggledad Jul 24, 2014 03:03 AM

Quote:

I think it would be a good solution, but unfortunately I also use my "ugly" categories for google analytics tracking (visits per category etc.). I use the Google Analytics for WordPress plugin by Joost de Valk for this, which uses the same WordPress function. If I hide the categories, I can no longer track them with GA... so this is no solution for me, I am afraid. Any other ideas?
If you hide the categories, how will you expect google to count them if they are hidden? I would expect Google to ignore/penalize hidden elements on a page.
Quote:

I read somewhere in the BFA forums that you could theoretically insert a widget into the footer, then execute php in it (with a plugin), and so check for the categories.
A long time age - before WordPress banned it - it was possible to put php in the theme options - BUT you can't anymore.
Quote:

Or alternatively there is a CSS function called after, which inserts text. If it is possible to insert a link with it, I could use CSS to insert links to categories into the kicker and footer if the post belongs to a certain category... sort of doing it the other way around.
None that I am aware of

Jerry_Q4d Jul 27, 2014 06:37 AM

I have found a simple solution :-)

Instead of trying to adapt the function displaying ALL categories, I went at it from the other side. I thought: All I want to do is display a list of categories - those which are useful to the user, not ALL categories.

So I edited the post info items, manually adding links for the categories I want, and giving them CSS classes so I could select them later with CSS commands.

Letīs say my categories are called "category1", "category2" etc. by wordpress. So I did this in the footer info items:

<span id="mycategory1"><a href:/link/to/wordpress/category1/ ...</a></span>
.. mycategory2 ...
etc.

then, in the CSS inserts, I added "display: none;" for all of these links:

#mycategory1 {
display: none;
}

So by default the links are there, but are not displayed. Crazy, eh?

Now I added another CSS item:

.category-category1 div.post-footer #mycategory1 {
display: inline;
}

and so on for all categories I created links for

The effect is that in posts which belong to category1, the CSS unhides the link by applying "display: inline,". In all other posts, the link stays hidden.

By this, I manage to create a footer which displays only the category links I need, and ONLY if the post belongs in the category.

Maybe this will be of help to somebody oneday, so if yes, please feel free to use it; hope I managed to explain the procedure properly.

Jerry_Q4d Sep 2, 2014 12:45 AM

I have noticed a strange thing: since the last Atahualpa update the code is broken. Maybe this is a bug in the last version. Apparently, the body of the whole site now gets the categories of the first post (on multi post pages). Dont know if it is just happening for me or always.

The result is that if you query the categories with css and show links for the appropriate categories of a post, you are always showing the categories of the first post also, which kind of breaks the whole idea. Is it something I can correct or is it an Atahualpa thing?

juggledad Sep 2, 2014 04:03 AM

A new feature was added in 3.7.17 to add the categories names to the body on single post pages. It does this by testing to see if the page is an archive pages (any multi post page). If so, it does not add the category names to the <body> statement.

Turns out that if you show your posts on the landing page, it is not considered an archive page like all other multi post pages.

see PATCH 3718-01: <body> statement shows category named when blog page is front page for a fix

Jerry_Q4d Sep 2, 2014 06:55 AM

Wow that was fast. You are great as always.


All times are GMT -6. The time now is 11:22 PM.

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