Category Archives: PHP

Caching large menus or header/footer links in WordPress

Even if you are not using some robust caching plugin or tool in wordpress you can cache small chunks of data using basic caching techniques of PHP. In my example i had been creating a few dozens of links in the footer i would cache my links part so every time my page loads wordpress does not have to create each and every link by querying the database for each individual link. Here’s the simple code: Continue reading

To check in a smarty template if it was the last page of the page results

Here’s a method to check in a smarty template if it was the last page of page results.

{if $listings.current_page gte ($listings.total / $results_per_page)|ceil}
    True
{else}
    False
{/if}

where $listings.current_page is the current page user is on, $listings.total is the number of totals results and $results_per_page is the number of listings or rows that are displayed on each page. “gte” is >= operator and |ceil as the mathematical modifier which returns next lowest integer.