Sunday 11 October 2015

Wordpress Add multiple custom fields to the general settings page

Add multiple custom fields to the general settings page



function register_fields()
{
    register_setting('general', 'my_first_field', 'esc_attr');
    add_settings_field('my_first_field', '<label for="my_first_field">'.__('My Field' , 'my_first_field' ).'</label>' , 'print_custom_field', 'general');
}

function print_custom_field()
{
    $value = get_option( 'my_first_field', '' );
    echo '<input type="text" id="my_first_field" name="my_first_field" value="' . $value . '" />';
}

add_filter('admin_init', 'register_fields');

Function Reference/get settings
Reading a settings Value in wordpress
<h1><?php echo get_settings('blogname'); ?></h1> 

Thursday 1 October 2015

Recent Post of Particular Parent Category

 Wordpress List Recent Post of Particular Parent Category


<?php $query = new WP_Query( 'category_name=blog&posts_per_page=5' );?>

    <ul>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
      <li> <a href="<?php the_permalink() ?>"><?php the_title();  ?> </a></li>
 <?php endwhile;?>
    </ul>

How to make Windows 7 bootable install USB stick

Install Windows 7 from a USB drive


Preparing the USB drive:
  1. Open command prompt as administrator - Right click on Start > All Programs > Accessories > Command Prompt and select Run as administrator or type cmd in the Start search bar.
  2. Run diskpart utility by typing diskpart into command prompt window and pressing “Enter”.
  3. Locate your USB drive disk number by executing list disk. We'll assume the USB drive is 1.
  4. Run the following commands:
    1. select disk 1
    2. clean
    3. create partition primary
    4. select partition 1
    5. active
    6. format fs=NTFS
    7. assign
    8. exit
Now we have prepared USB drive. Lets make it bootable:
  1. Insert Windows 7, 32/64-bit installation disk into DVD drive. Let's assume it's D
  2. Go to D:\boot (cd d:\boot)
  3. If your USB drive letter is “e” please run bootsect /nt60 e:
  4. Copy DVD Windows 7 media content to USB root folder (etc. don't put it into any folder)

  1. Install Windows 7 from a USB drive 
cmd-prompt-usb-bootable

Next type
DISKPART
this loads the diskpart application we need to proceed
Then type
LIST DISK
the image above shows our 32 GB USB drive is listed as DISK 2
so you have to type
SELECT DISK 2 (your USB Drive may have a different number, don’t follow exactly this text it depends on your usb drive)
You will get a successful response “Disk 2 is now the selected disk”
Clean Cmd USB Drive
Next we want to clean the USB drive
Type:
CLEAN
you will get a successful response ‘DiskPart succeeded in cleaning the disk”.
Clean USB Drive

After the drive is cleaned follow the list in the image above (detailed below in list order) – you can also note the successful text responses from the OS as you enter each command.
SELECT DISK 2 (or what number your USB drive has)
CREATE PARTITION PRIMARY
SELECT PARTITION 1
ACTIVE
FORMAT FS=NTFS
Formatting can take a little time depending on the size of the drive, our 32GB unit took about 10 minutes to format - you will see a percentage readout until it is finished.
Bootable USB Final Cmd Prompt
Next type:
ASSIGN
EXIT (DISK PART will exit)
Type D: CD BOOT (substitute the “D” if necessary with the letter of your Windows 7 DVD drive)
then key
CD BOOT
then
BOOTSECT.EXE /NT60 E: (substitute the “E” if necessary with the letter of your now ready USB drive) – we are telling the system to create a boot sector file on the USB drive.
Now you can exit the command prompt and copy all the files on the Windows 7 DVD to the USB drive.
Once this step is finished you’ll be ready to boot from this drive, all you need to do is configure your motherboard bios setup to boot first from USB rather than hard drive or optical drive. If you don’t know how to do this, refer to your specific motherboard manual or search the internet.