Wordpress

1.How to increase the meomary allocation while we get the fatal error?


wp-config.php file:Increasing memory allocated to PHP


define('WP_MEMORY_LIMIT', '128M');


2.How can we send the mail in wordpress?
In wordpress for get the mail functionality we need to install and enable the WP-EMail and WP-Mail-SMTP plugins

if ($res == 'true') {
$headers = "MIME-Version: 1.0\n";
$headers .= "From: NH Hospitals <"ravi.karnati.php5@gmail.com">\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\" \n";
$mail_to = 'pamidipadudravid@gmail.com';
$title = 'Job application';
$title2 = $name . ' Job application';
$message2 = "Hi, How are u? This is the message for body part";
if ($resume_type == 'Paste') {
wp_mail($mail_to, $title, $message2, $headers);
} else {
$attachments = array ($userfile);
$te = wp_mail($mail_to, $title, $message2, $headers, $attachments);
}
}




3.Running Notes


1.teaser is also known as Ecerpt <?php the_excerpt(); ?> , in editor also we can set this option while we post the post
2.we can able to write the styles for print indiduvally
3.we can able to write the alt text font styles  to image using img {font-size:12px}
4.<?php wp_get_archives('type=monthly'); ?>
  <?php wp_get_archives('type=postbypost&limit=15'); ?>
  <?php c2c_get_recently_commented(5); ?>
  <?php related_posts(10, 10, '<li>', '</li>', '', '', false, false); ?>
  <?php get_links_list(); ?>
  <?php echo '<a href="' . $user->user_url . '">' . $user->display_name . '</a>'; ?>
  <?php get_sidebar(); ?>
  <?php include ('sidebar2.php'); ?>
  the_post();
  the_content();
  add_theme_support( 'post-thumbnails' ); 
    has_post_thumbnail()
    the_post_thumbnail()
    <?php set_post_thumbnail_size( $width, $height, $crop ); ?>   -> Default sizes for thubnails
    <?php add_image_size( $name, $width, $height, $crop ); ?> 

5.Template Files List ?  
   style.css - mandotory file
   index.php
   comments.php
   front-page.php
   home.php
   single.php
   single-<post-type>.php
   page.php
   category.php
   search.php
   date.php
   archive.php
   author.php
6.Template varibles used in Template Files?
  get_header()
  get_sidebar()
  get_footer()
  get_search_form()
  <?php register_nav_menus(); ?>


  <?php
  $post = $wp_query->post;
  if ( in_category( '9' ) ) {
     get_template_part( 'single2' );
       } else {
    get_template_part( 'single1' );
   }
  ?>


  wp_nav_menu();
  previous_post_link() and next_post_link().

7.Functions

  <?php wp_list_pages('exclude=17,38' ); ?>
  the_date()
  the_time()
  
8.Hook_filter
  Hook_actions

9.<!-- Start the Loop. -->
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

 <!-- The following tests if the current post is in category 3. -->
 <!-- If it is, the div box is given the CSS class "post-cat-three". -->
 <!-- Otherwise, the div box will be given the CSS class "post". -->
 <?php if ( in_category('3') ) { ?>
           <div class="post-cat-three">
 <?php } else { ?>
           <div class="post">
 <?php } ?>

 <!-- Display the Title as a link to the Post's permalink. -->
 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

 <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
 <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>

 <!-- Display the Post's Content in a div box. -->
 <div class="entry">
   <?php the_content(); ?>
 </div>

 <!-- Display a comma separated list of the Post's Categories. -->
 <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
 </div> <!-- closes the first div box -->

 <!-- Stop The Loop (but note the "else:" - see next line). -->
 <?php endwhile; else: ?>

 <!-- The very first "if" tested to see if there were any Posts to -->
 <!-- display.  This "else" part tells what do if there weren't any. -->
 <p>Sorry, no posts matched your criteria.</p>

 <!-- REALLY stop The Loop. -->
 <?php endif; ?>

10.plugins_url( 'myscript.js', __FILE__ ); ( By using this function we can include js into our plugin)


11.<?php while ( have_posts() ) : the_post(); ?>
      <p><?php the_content(); ?></p>
      <?php endwhile; // end of the loop. ?>



12.<?php $the_query = new WP_Query( 'page_id=84' );
while ( $the_query->have_posts() ) : $the_query->the_post();?>

13.How can we print the page?

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content('Read more'); ?>
<?php endwhile; ?>
<?php endif; ?>


4.Simple Form in Custom page?





<?php
/*
Plugin Name: ramesh Estimation
Version: 1.0
Description: Just a test plugin!
Author: ramesh
Author URI: http://URI_of_plugin_author_website
Plugin URI: http://URI_of_plugin_descripion_and_updates
License: A slug describing license associated with the plugin (usually GPL2)
*/
?>
<?php
   
        function contact_function($atts){
?>
    <form name="login" method="post" onsubmit="return validate()">
<h1>ESTIMATION GRATUITE</h1>
<h4>Pour contacter Life Style Immobilier, remplissez notre formulaire :</h4>
<div class="text-type3">
<p class="estimation" > Vous souhaitez vendre : </p>
<p class="radio"><input type="radio" class="styled" value="1" name="5"></p>
<p class="estimation">Un appartement</p>
<p class="radio"><input type="radio" class="styled" value="1" name="5"></p>
<p class="estimation">Une maison</p>
</div>
<div class="clear">
<div class="left-form">
<p><input name="nom" type="text" value="NOM" onclick="this.value='';" onfocus="this.value=(this.value=='NOM') ? '' : this.value;" onblur="this.value=!this.value?'NOM':this.value;" /></p>
<p><input name="prenom" type="text" value="PRENOM" onclick="this.value='';" onfocus="this.value=(this.value=='PRENOM') ? '' : this.value;" onblur="this.value=!this.value?'PRENOM':this.value;" /></p>
<p><input name="email" type="text" value="EMAIL" onclick="this.value='';" onfocus="this.value=(this.value=='EMAIL') ? '' : this.value;" onblur="this.value=!this.value?'EMAIL':this.value;" /></p>
<p><input name="telephone" type="text" value="TELEPHONE" onclick="this.value='';" onfocus="this.value=(this.value=='TELEPHONE') ? '' : this.value;" onblur="this.value=!this.value?'TELEPHONE':this.value;" /></p>
<p><input name="ville" type="text" value="VILLE" onclick="this.value='';" onfocus="this.value=(this.value=='VILLE') ? '' : this.value;" onblur="this.value=!this.value?'VILLE':this.value;" /></p>
</div>
<div class="right-form">
<p class="textarea2"><textarea name="votremessage" value="Votremessage" cols="" rows="" onclick="this.value='';" onfocus="this.value=(this.value=='Votre message') ? '' : this.value;" onblur="this.value=!this.value?'Votre message':this.value;">Votremessage</textarea></p>
</div>

</div>
<input type="submit" value="ENVOYER" name="button" class="button-submit" />
<p class="text-type1">Vous pouvez également directement nous contacter au 04 50 52 65 77 pour discuter de votre projet.</p>
<?php
}
add_shortcode('Estimation', 'contact_function');
add_action('wp_head','add_javascript_fun');




?>


<?php
function add_javascript_fun(){
?>   


<script language="javascript" type="text/javascript">






function validate(){
       
        var nom = document.login.nom.value;
        var prenom=document.login.prenom.value;
        var email=document.login.email.value;
        var telephone=document.login.telephone.value;
var velle=document.login.velle.value;
        var votremessage=document.login.votremessage.value;
        if(nom=="NOM"){
                alert("Enter nom");
                document.login.nom.focus();
                return false;  
        }
       
        if(prenom=="PRENOM"){
                alert("Enter prenom");
                document.login.prenom.focus();
                return false;  
        }
        if(email=="EMAIL"){
                alert("Enter email");
                document.login.email.focus();
                return false;  
        }
else{
var x=document.forms["login"]["email"].value;
        var atpos=x.indexOf("@");
        var dotpos=x.lastIndexOf(".");
        if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
        {
          alert("Not a valid e-mail address"); 
 document.login.email.focus();
        return false;
       }
        }
        if(telephone=="TELEPHONE"){
                alert("Enter telephone");
                document.login.telephone.focus();
                return false;  
        }
if(isNaN(TELEPHONE))
{
alert("Enter the valid Mobile Number(Like : 9566137117)");
document.login.TELEPHONE.focus();
return false;
}
if(TELEPHONE.length < 1 || TELEPHONE.length > 10)
{
alert(" Your Mobile Number must be 1 to 10 Integers");
document.login.TELEPHONE.select();
return false;
}
if(velle=="VILLE"){
                alert("Enter ville");
                document.login.velle.focus();
                return false;  
        }
if(votremessage=="Votremessage"){
                alert("Enter votremessage");
                document.login.votremessage.focus();
                return false;  
        }
        return true;
       
       
}










</script>




<?php
}
?>

5.How can we put the  individual  header banner image for individual page?


1. first thing is select the image for page in media using ' attached to page ' field


2. add this code in 'header.php'  




<div class="header-banner"><span><?php echo doHeroTagline($post->ID); ?></span><?php echo doHeroImage($post->ID); ?></div>

3. add this code in 'function.php' 


function doHeroImage($id) {

$size = 'hero';


$image = get_the_post_thumbnail($id, $size);


if (empty($image)) {
global $post;
if (is_page()) {
foreach($post->ancestors as $ancestor) {
$image = get_the_post_thumbnail($ancestor, $size);
if (!empty($image)) break;
}
} elseif ($post->post_type == 'post') {
// $image = get_the_post_thumbnail('10');

if (empty($image)) {
$post = get_option('page_for_posts');
$image = get_the_post_thumbnail($post, $size);
}
}
}


if (empty($image)) {
$home = get_option('page_on_front');
$image = get_the_post_thumbnail($home, $size);
}
return str_replace('http:','', $image);
}


function doHeroTagline($id) {


// don't run on the main loop page!
if (empty($tagline)) $tagline = get_post_meta($id, '_custom_custom_tagline', true);


if (strlen($tagline) == 0) {
global $post;


if (is_page()) {
foreach($post->ancestors as $ancestor) {
$tagline = get_post_meta($ancestor, '_custom_custom_tagline', true);
if (strlen($tagline) > 0) break;
}
} elseif (is_home()) {
$post = get_option('page_for_posts');
$tagline = get_post_meta($post, '_custom_custom_tagline', true);
}


}


if (empty($tagline)) {
$home = get_option('page_on_front');
$tagline = get_post_meta($home, '_custom_custom_tagline', true);
}


return $tagline;


}


6.How can we  get the  menu as a list of pages created in site?

add this line in where ever you want, example in generally menu in header , so add this code in header.php

<?php wp_list_pages('title_li=&depth=3&sort_column=menu_order&exclude=33,163,181,');?>




7,How can you create the forms by  wordpress admin


just use 'Gravity Forms' plugin
put this  short code in plugin  [gravityform id=3 name=ContactUs title=false description=false]


7.What quaries we need to run while we dump the live siteinto localhost?


UPDATE wp_posts SET guid = REPLACE (guid,'http://www.narayanahospitals.com','http://localhost/narayanahospitals');

UPDATE wp_posts SET post_content = REPLACE (post_content,'http://www.narayanahospitals.com','http://localhost/narayanahospitals');

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value,'http://www.narayanahospitals.com','http://localhost/narayanahospitals');

UPDATE wp_options SET option_value = REPLACE (option_value,'http://www.narayanahospitals.com','http://localhost/narayanahospitals');