Monday, September 24, 2012

How to Disable Plugin and Theme Update and Installation on WordPress

Add this constant to your wp-config.php file to disable plugin and theme updates/installation:

define('DISALLOW_FILE_MODS',true);

Monday, September 3, 2012

Get the page ID by the page name

function get_id_by_post_name($post_name)
{
global $wpdb;
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$post_name."' AND post_status='publish'");
return $id;


 

Saturday, September 1, 2012

How To Create A Custom Page Template In WordPress

To create a WordPress Page Template, you’ll need to use your text editor. Go to the directory on your server where you installed WordPress, and then navigate to the directory of your theme. Usually that looks something like this: “/wp-content/themes/default” where “default” is your theme name.

That’s where you will create your custom page template file. Create a file called “cover_page.php” and add the following code to it:
<?php /* Template Name: Cover Page */ ?>
<?php get_header(); ?>
Here's my cover page!
<?php get_footer(); ?>


<?php if (is_page_template('cover_page.php') ) 
{ ?>    <p>Apples</p>    <?php } 
else { ?>    <p>Oranges</p>    <?php } ?>