Move the category title above the post title?
Best Answer evanders , 29 January 2013 - 03:01 AM
Nevermind. Figured it out:
/* Prints the post category above post title */
add_filter('pagelines_post_title_output','category_above_title');
function category_above_title($title){
$category = get_the_category();
if($category[0]){
$category_name .= '<span class="categories sc"><a class="category" href="'.get_category_link($category[0]->term_id ).'">'. $category[0]->cat_name.'</a></span>';
}
$title = $category_name . $title;
return $title;
}
//end function
Enjoy!
Go to the full post
#1
Posted 27 January 2012 - 06:25 PM
#2
Posted 27 January 2012 - 07:24 PM
#3
Posted 02 February 2012 - 04:24 PM
#4
Posted 02 February 2012 - 05:30 PM
Give thanks to @pross
#5
Posted 02 September 2012 - 03:07 AM
#6
Posted 02 September 2012 - 10:19 AM
#7
Posted 03 September 2012 - 06:46 PM
#8
Posted 03 September 2012 - 10:30 PM
#9
Posted 26 January 2013 - 06:43 AM
Thanks for the tip. I messed with this, and while a good start, didn't completely meet my needs. What I more specifically want to do is place the Category title directly above the Post Title. Using the action the_post, while a good start, put it in the the Loop, but it ends up above the thumbnail.
I did some sleuthing, however, and found that I could accomplish this using the filter: pagelines_post_title_output, as outlined here:
.
The question is, how to write the code properly in my functions.php file. I'm getting better at writing these, but this one has me stumped. I think the reason why is I'm trying not only to display the category title, but only one category title and display it as a hyperlink. I know I can accomplish that using this code:
I've been trying like mad to use this code along with the previously mentioned filter to make it work. I feel like I"m close, but I can't nail it.
Any help would be really appreciated.
For what it's worth, this is what I have now:
#10
Posted 27 January 2013 - 09:47 AM
#11
Posted 28 January 2013 - 02:12 AM
Sure. As context, I achieved the current style (see:
) using the following hook:
The only problem with this is it adds the category at the top of the "the_post", which is above the thumbnail image. I want this directly above the post title, below the thumbnail, like this:
#12
Posted 28 January 2013 - 02:17 AM
Whoops, this is an image of what I am trying to achieve:
#13
Posted 28 January 2013 - 07:52 AM
With your site being in dev environment, its difficult to assist you further. What I suggest is installing Action Map which is a free plugin on the PageLines store and once active, will display all available hooks on your page, which you can then use in your code.
As I think the hook you're currently using isn't the correct one, especially if you wish to have it above the image, from your screenshot.
#14
Posted 29 January 2013 - 01:57 AM
OK. Thanks. What I think I really need is a developer that knows PHP. It's probably a simple solve.
#15
Posted 29 January 2013 - 02:34 AM
Hi,
We have a number of pro developers available at
#16
Posted 29 January 2013 - 02:48 AM
I think I figured it out out. Except instead of just outputing the category, it outputs the word "Array" in front of the category.
If anyone doesn't mind taking a look at this code and letting me know what I did wrong, I'd have an answer and the community would have a helpful tip:
#17
Posted 29 January 2013 - 03:01 AM Best Answer
Nevermind. Figured it out:
Enjoy!











