Select Page

Automatically show child pages and custom fields WorldPress

This code will allow you to automatically show child pages including custom fields in this case one called ‘desc’ You will need to add this code to your template file for example page.php <?php $child_pages = $wpdb->get_results("SELECT * FROM...

Display a Random Header Image on Your WordPress Blog

Upload some images named 1.jpg, 2.jpg, 3.jpg and so on to your your wp-content/themes/yourtheme/images directory. Open header.php and paste the following code in it: <?php $num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of...

Remove RSS feeds from WordPress site

Add this to your functions.php file to disable any RSS feeds. function fb_disable_feed() { wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') ); } add_action('do_feed', 'fb_disable_feed', 1);...

Target certain pages using WordPress

Use this code to stop the title of the page such as ‘Home’ from being displayed as the H1 on the homepage. <?php if (!is_page('Home')) { ?> <h1><?php the_title(); ?></h1> <?php }...

WordPress if page exists code

Use this to target code if a certain page exists, useful to show gallery images in a sidebar if there is a gallery page. <?php if(get_page_by_title('Gallery')) : {code here} endif; ?>