A bit of PHP

Up a level : Programming
Next page : Previous Up Next - Pun

I wanted to add links to the previous and next pages at the same level.To start with I added the Next Page, Not Next Post plug in. You can find information about the plugin at https://binarym.com/2009/next-page-not-next-post/.

I could then manually add [previous_page] and [next_page]  anchor texts on each page, but that would take time, and would not be particularly flexible. What I did instead was to create a child theme, and in that I added a filter to the functions.php file.

A filter is basically some process that the a page has  to go through before it is sent to the visitor.

In this case I want the filter to add  [previous_page] and [next_page] to the header and footer of the page, and also some vertical lines to frame the text. I also have a few pages where  I don’t want this to happen. I add the tag [pnp], but with n instead of p and p instead of n somewhere in the beginning of such a page. (I am somewhat proud of that I though of not writing the actual tag on this page.)

If such a tag is on the page it is overwritten, else texts are added at top of and at the end of the contents. This is the code:

I also added a time stamp of the time of the latest change in the footer.

 

 

Up a level : Programming
Next page : Previous Up Next - PunLast modified: Jan 22, 2017 @ 17:55