Archived

This topic is now archived and is closed to further replies.

  • 0

Add Code To Blog Page Template

Question

Posted · Report post

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.

Share this post


Link to post
Share on other sites

7 answers to this question

Posted · Report post

Hi there, if you download the action map plugin you'll be able to see where the actions are on the template. http://www.pagelines.com/store/plugins/pagelines-action-map/

 

Or you can check out http://api.pagelines.com/hooks 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 :-)

 

http://www.pagelines.com/store/plugins/hooker/

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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

Share this post


Link to post
Share on other sites

Posted · Report post

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

Share this post


Link to post
Share on other sites

Posted · Report post

Correct, you will not loose any changes you make, for more information on child themes, read the Wordpress codex - http://codex.wordpress.org/Child_Themes

Share this post


Link to post
Share on other sites