Jump to content


Photo
- - - - -

Displaying A Post's Category


  • Please log in to reply
10 replies to this topic

#1 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 25 April 2013 - 02:06 AM

So on Climbur.com I want to be able to have text like this at the top of each post underneath the post title:

 

This story will inspire you to CREATE.

 

or 

 

This story will inspire you to THINK.

 

The words in all caps are my categories on the site. How do I make it so I can add this text and automatically pull in the text with the category name (where it's in all caps)?

 

Thanks!



#2 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 25 April 2013 - 03:00 AM

Hi there

 

To achieve this you'll need to use a hook to insert some code into the relevant position on the page. You can use the actionmap plugin from the store to find the position you want the text to appear, then use either hooker plugin to insert the code. You can find out more about hooks here

Please Login or Register to see this Hidden Content

 

I'm not a developer, but I think the code you'll need to insert into the hook will look something like the following

Please Login or Register to see this Hidden Content



#3 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 01 May 2013 - 04:46 PM

Thanks James. Do you know how to make the category itself a link?



#4 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 01 May 2013 - 04:48 PM

Also, that didn't work :) It just displayed a period and no text/category...



#5 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 01 May 2013 - 04:57 PM

This may be what you're looking for:

Please Login or Register to see this Hidden Content



#6 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 01 May 2013 - 05:01 PM

Thanks. I just tried putting in: <?php get_category_link$category_id ); ?> 

 

Using the pagelines_loop_before_post_content hook and it displayed nothing...



#7 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 01 May 2013 - 07:05 PM

Ah, okay. This one should be the one you use:

Please Login or Register to see this Hidden Content

(please follow directions for use)



#8 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 01 May 2013 - 07:13 PM

Thanks for sticking with me on this subject trying to solve it. Unfortunately, not a single example from that page works via the hook editor. It always outputs partial code, but no Category/Link. 



#9 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 01 May 2013 - 07:25 PM

Hm, and is this on an individual post page or a post within the blog page?



#10 climbur

climbur

    Advanced Member

  • Members
  • 33 posts
  • Country: Country Flag

Posted 01 May 2013 - 07:28 PM

This is on an actual post itself. See screenshot.

 

Please Login or Register to see this Hidden Content



#11 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 02 May 2013 - 12:28 AM

Hi there,

 

To enable php to be used within the hooker plugin you'll need to add define( 'PL_HOOKS_PHP', true ); to the wp-config first as mentioned in the plugin instructions. Hooker will only allow html/js/css by default, php will need to be added using that code.