Jump to content


Photo
- - - - -

Add Code To Blog Page Template


  • Please log in to reply
7 replies to this topic

#1 maxpower1

maxpower1

    Member

  • Members
  • 14 posts
  • Framework Version:Developer
  • Country: Country Flag

Posted 06 December 2012 - 01:00 AM

I have php mobile redirection code that I need to add to blog page template.  I understand it is deemed a "special page", but how do I add the code via functions.php?

 

Thanks.



#2 James B

James B

    Advocate

  • Members

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

Posted 06 December 2012 - 01:59 AM

Hi there, if you download the action map plugin you'll be able to see where the actions are on the template.

Please Login or Register to see this Hidden Content

 

Or you can check out

Please Login or Register to see this Hidden Content

where there's a written list.

 

When you've chosen the action you want to use, then you can insert your code via a hook in the functions.php. Or you could use the new hooker plugin which is literally a case of select which hook and copy/paste/save :-)

 

Please Login or Register to see this Hidden Content



#3 maxpower1

maxpower1

    Member

  • Members
  • 14 posts
  • Framework Version:Developer
  • Country: Country Flag

Posted 06 December 2012 - 03:13 AM

The Hooker plug in looks great, but...  

 

I only need to add code to the absolute top of blog page.  This is not global redirection code, only certain templates require it.  I have the code placed on all page.php templates that require it, except I cannot find template for blog page.

 

Is there a hook specifically for this.  I cannot see it in the list.

 

Thanks.



#4 James B

James B

    Advocate

  • Members

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

Posted 06 December 2012 - 05:02 AM

Well from what I can see there isn't a template specifically for the blog template. It's dynamically created from the database calling in the required sections and class.posts.php. I'd imagine if it was possible you'd have to use some php to target that prior to using the hook to insert the code, as the first hook called on the page would be 'pagelines_before_html'.

 

I'll need to check with a developer if this if possible. So leave it with me and someone will come back to you shortly.

 

Have you inserted the code into the other page templates you mentioned using the functions.php or by actually editing the core files? We don't advise you edit any core files as any changes will get wiped on update.



#5 maxpower1

maxpower1

    Member

  • Members
  • 14 posts
  • Framework Version:Developer
  • Country: Country Flag

Posted 06 December 2012 - 11:34 AM

We have edited the core files for now.  Any recommendations for adding code to page templates via functions.php?



#6 Danny

Danny

    Is Awesome!

  • Moderators
  • 15907 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 06 December 2012 - 12:40 PM

Hi, You will need to use the Wordpress conditional tag is_page

Please Login or Register to see this Hidden Content

Off the top the head, I think its is_page(blog)

#7 maxpower1

maxpower1

    Member

  • Members
  • 14 posts
  • Framework Version:Developer
  • Country: Country Flag

Posted 11 December 2012 - 10:54 AM

We are running a child theme.  If I edit the template files in there, I should not lose any changes when updating framework, correct?



#8 Danny

Danny

    Is Awesome!

  • Moderators
  • 15907 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 11 December 2012 - 11:10 AM

Correct, you will not loose any changes you make, for more information on child themes, read the Wordpress codex - 

Please Login or Register to see this Hidden Content