wordpress query

-

-

1-How to change or replace all string in all table or entire database
UPDATE wp_options a,wp_users b,wp_posts c,wp_links d SET
a.option_value = REPLACE (a.option_value,’uni-50/bseionline’,'projectdesk.us/bseionline’),
b.user_url = REPLACE (b.user_url,’uni-50/bseionline’,'projectdesk.us/bseionline’),
c.post_content = REPLACE (c.post_content,’uni-50/bseionline’,'projectdesk.us/bseionline’),
c.guid = REPLACE (c.guid,’uni-50/bseionline’,'projectdesk.us/bseionline’),
d.link_url = REPLACE (d.link_url,’uni-50/bseionline’,'projectdesk.us/bseionline’),
d.link_notes= REPLACE (d.link_notes,’uni-50/bseionline’,'projectdesk.us/bseionline’),
d.link_rss= REPLACE (d.link_rss,’uni-50/bseionline’,'projectdesk.us/bseionline’)

2- Where set database name ,user name ,and password for site

define(‘DB_NAME’, ‘wordpress_edu’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_HOST’, ‘localhost’);
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ”);

3-what should be done if your database destroy or delete through any causes

open this file in your project on server :

file “install.php ”

its  create again a fresh database

4-How to insert record inj database in wordpress

$name=$_POST['Name'];
$email=$_POST['Email'];
$company=$_POST['Company'];
$phone=$_POST['Phone'];
$comment=$_POST['Comments'];
$submit=$_POST['submit'];

if(isset($_POST['submit']) )
{

$result=$wpdb->insert(‘wp_contactus’,array

(‘name’=>$name,’email’=>$email,’company’=>$company,’phn_no’=>$phone,’comments’=>$comment));
if($result)
{
//wp_redirect(get_option(‘siteurl’).’/contact-us?ref=5′);
}
else {
$msg=”There is some problem”;
}

}

5-what script  use for find base url  or site home path in wordpress

echo get_option(‘siteurl’);

echo get_option(‘home’)

eg:-

<?php echo get_option(‘siteurl’).’/wp-content/uploads/2010/11/header_contact.jpg’;?>

6:- How to create own template in wordpress

create  a php page in given  folder

project/wp-content/theme/themefolder/own-template.php

<?php
/*
Template Name: own-template
*/

get_header();

write here your content or template design

get_footer();

?>

7- How to create plugin in wordpress

create a folder in like this path

eg you create  a plugin for contact form

create a file contact.php and according this path

project/wp-content/plugins/contact/contact.php

and write in this file:

<?php
/*
Plugin Name: Contact
Plugin URI:
Description: Contact.
Author:
Version: 1.2010.1
Author URI:
*/
if ( ! defined( ‘WP_CONTENT_URL’ ) )
define( ‘WP_CONTENT_URL’, get_option( ‘siteurl’ ) . ‘/wp-content’ );
if ( ! defined( ‘WP_PLUGIN_URL’ ) )
define( ‘WP_PLUGIN_URL’, WP_CONTENT_URL. ‘/plugins’ );
if ( ! defined( ‘CONTACT_TABLE’ ) )
define( ‘CONTACT_TABLE’,$wpdb->prefix.”contactus”);
if (!class_exists(‘contact’)) {
class contact {
var $options = array();
function contact() {
$this->__construct();
}
function __construct() {
$this->addHeaderCode();
$this->getOptions();
add_action(“admin_menu”, array(&$this,”tpm_admin_actions”));
}
function getOptions() {
if (!$theOptions = get_option($this->optionsName)) {
$theOptions = array(‘default’=>’options’);
update_option($this->optionsName, $theOptions);
}
$this->options = $theOptions;
}
function addHeaderCode() {
if (function_exists(‘wp_enqueue_script’)) {
}
}

/* this  create  contact menu in your admin side*/

function tpm_admin_actions() {
add_menu_page(‘Contact’, ‘Contact’, 10,basename(__FILE__).’/contactus’, array(&$this,’admin_menu_contactus’));
add_submenu_page(basename(__FILE__).’/contactus’,'Contact Us’,'Contact Us’,10,basename(__FILE__).’/contactus’, array(&$this,’admin_menu_contactus’));
}
function admin_menu_contactus() {
include(‘contactus.php’);
}
}
}
if (class_exists(‘contact’)) {
$contact = new contact();
}

Question :-  How to add breadcrumbs in wordpress ?

Answer:-

function fckbreadcrumbs(){

//global $post;
//$content = $post->post_content;

$content = get_the_content($more_link_text, $stripteaser);
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]&gt;’, $content);

$b=breadcrumbs();
$dd=str_replace(‘fck::breadcrumbs’,$b,$content);
return $dd;

}

function breadcrumbs(){

global $post;
$content = $post->post_content;
$PParent = get_parent_title($post->post_parent);
$PTitle = $post->post_title;
$post_name = $post->post_name;
$parent_slug = get_parent_slug($post->post_parent);

$baseurl=site_url();
$parentUrl=$baseurl.’/’.$parent_slug;
$singlePageUrl=$baseurl.’/’.$post_name;
$currenturl=$baseurl.’/’.$parent_slug.’/’.$post_name;

$Pcrumbs=”;
if($PTitle==”){
$Pcrumbs=’<a href=”‘.$baseurl.’”> Home</a>’;
}
if($PParent==”){
$Pcrumbs=’<a href=”‘.$baseurl.’”> Home</a> | ‘.
‘<a href=”‘.$singlePageUrl.’”> ‘.$PTitle.’</a>’;
}
if($PParent!=”){
$Pcrumbs=’<a href=”‘.$baseurl.’”> Home</a> | ‘.
‘<a href=”‘.$parentUrl.’”> ‘.$PParent.’</a> |
<a href=”‘.$currenturl.’”>’.$PTitle.’</a>’;
}
return $Pcrumbs;
}

Leave a Reply