Fatal error: Call to undefined function post_exists()

The files in wp-admin are only loaded when you’re in the admin area… when you’re looking at pages or posts those functions aren’t loaded. In that case you’d need to require the file first, so you’d want to do something like this in your function:

WooCommerce Conditional Tags

All conditional tags test whether a condition is met, and then return either TRUE or FALSE. WooCommerce page is_woocommerce() Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included). Main shop page is_shop() Returns true when on the product archive page (shop). Product category page … Continued

Laravel Project Setup

Install via Composer You can install Laravel by issuing the Composer create-project command in your terminal: Once the project is installed you can view in your brower, you will need to point your local server to the public folder. Or you can also run the following command to start a development server on http://127.0.0.1:8000. Once … Continued

How do I get PHP errors to display?

Display errors is usually always turned off in the php.ini or your Apache config file to stop the wrong people seeing details of your server if something goes wrong. When debugging code I always add the following three lines to the top of the script I am looking at: That prints out all the errors I need.

PHP

Responsive Web Design – Device Breakpoints

There are loads of screens and devices with different heights and widths. More often than not I will use Bootstrap in the core of any builds I do and that takes care of 95% of my responsive requirements. However knowing the following breakpoints is very useful when wanting to apply certain styles for certain screen … Continued

CSS

Linking to JSON data from dist folder

One of the problems I came across recently whilst using Webpack was the fact that once yarn build -p had been run all the assets are given hashed filenames, such as: data.8687234d3.json But the JavaScript I had written was looking for and trying to load data from data.json. Webpack takes care of all the typical … Continued

How to Secure Apache with Let’s Encrypt on CentOS 7

A huge thank you to Digital Ocean for their tutorials, everything below has been taken from them, only just scaled back to the bare minimum to get the job done. If you want to go through their full article on setting up Let’s Encypt you can click here. Introduction Let’s Encrypt is a Certificate Authority (CA) … Continued

WordPress setup_postdata()

You must use $post and global $post. global $post; $args = array( ‘numberposts’ => 5, ‘offset’=> 1, ‘category’ => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ){ setup_postdata($post); echo the_title(); } wp_reset_postdata();