######Show post on the home page ######
<?php query_posts('p=id'); ?> /// example query_posts('p=21') 21 is post id //
<?php while (have_posts()) : the_post(); ?>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php endwhile;?>
#########activate plugin create table and deactive delete table ##########
<?php
function myplugin_activate()
{
global $wpdb;
$tablename = 'user_file';
$table = $wpdb->prefix . $tablename;
$sql= "CREATE TABLE $table
(fileID INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
userID INT( 7 ) NOT NULL ,
userName VARCHAR(250),
fileDescription MEDIUMTEXT NULL ,
fileName VARCHAR( 250 ) NULL ,
fileUploadedOn DATETIME NOT NULL )";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
function myplugin_deactivate()
{
global $wpdb;
$tablename = 'user_file';
$table = $wpdb->prefix . $tablename;
$wpdb->query("DROP TABLE IF EXISTS ".$table);
}
register_activation_hook( __FILE__, 'myplugin_activate' );
register_deactivation_hook( __FILE__, 'myplugin_deactivate');
?>
##### show plugin in the widget ######
<?php
function viral_video()
{
echo "<h2>viral video voodoo</h2>";
}
function widget_viral_video($args) {
extract($args);
echo $before_widget;
echo $before_title;?>My Widget Title<?php echo $after_title;
viral_video();
echo $after_widget;
echo "hello"; ###### show msg on the front end ####
}
function viral_video_init()
{
register_sidebar_widget(__('viral video voodoo'), 'widget_viral_video');
}
add_action("plugins_loaded", "viral_video_init");
?>
### create short code of the plugin #####
<?php
//[foobar]
function foobar_func()
{
echo "hellooooo";
}
add_shortcode( 'foobar', 'foobar_func' ); // foobar is short code and foobar_func is function name
?>
<?php add_filter( 'widget_text', 'do_shortcode' ); // this code use in function.php to execute short code in the widget
echo do_shortcode( '[shortcode title here]' ); // this code short code execute in the template file or anywhere in the site
?>
###### create custom post #####
<?
function manager_install() {
manager_create_post_type();
}
add_action( 'init', 'manager_create_post_type' );
function manager_create_post_type() {
register_post_type( 'manager',
array(
'labels' => array(
'name' => __( 'manager' ),
'singular_name' => __( 'manager' ),
'add_new' => __('Add New', 'manager'),
'add_new_item' => __('Add New manager'),
'edit_item' => __('Edit manager'),
'new_item' => __('New manager')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products'),
'supports' => array(
'title',
'thumbnail',
'comments',
'editor')
)
);
}
?>
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
<?php query_posts('p=id'); ?> /// example query_posts('p=21') 21 is post id //
<?php while (have_posts()) : the_post(); ?>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php endwhile;?>
#########activate plugin create table and deactive delete table ##########
<?php
function myplugin_activate()
{
global $wpdb;
$tablename = 'user_file';
$table = $wpdb->prefix . $tablename;
$sql= "CREATE TABLE $table
(fileID INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
userID INT( 7 ) NOT NULL ,
userName VARCHAR(250),
fileDescription MEDIUMTEXT NULL ,
fileName VARCHAR( 250 ) NULL ,
fileUploadedOn DATETIME NOT NULL )";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
function myplugin_deactivate()
{
global $wpdb;
$tablename = 'user_file';
$table = $wpdb->prefix . $tablename;
$wpdb->query("DROP TABLE IF EXISTS ".$table);
}
register_activation_hook( __FILE__, 'myplugin_activate' );
register_deactivation_hook( __FILE__, 'myplugin_deactivate');
?>
##### show plugin in the widget ######
<?php
function viral_video()
{
echo "<h2>viral video voodoo</h2>";
}
function widget_viral_video($args) {
extract($args);
echo $before_widget;
echo $before_title;?>My Widget Title<?php echo $after_title;
viral_video();
echo $after_widget;
echo "hello"; ###### show msg on the front end ####
}
function viral_video_init()
{
register_sidebar_widget(__('viral video voodoo'), 'widget_viral_video');
}
add_action("plugins_loaded", "viral_video_init");
?>
### create short code of the plugin #####
<?php
//[foobar]
function foobar_func()
{
echo "hellooooo";
}
add_shortcode( 'foobar', 'foobar_func' ); // foobar is short code and foobar_func is function name
?>
<?php add_filter( 'widget_text', 'do_shortcode' ); // this code use in function.php to execute short code in the widget
echo do_shortcode( '[shortcode title here]' ); // this code short code execute in the template file or anywhere in the site
?>
###### create custom post #####
<?
function manager_install() {
manager_create_post_type();
}
add_action( 'init', 'manager_create_post_type' );
function manager_create_post_type() {
register_post_type( 'manager',
array(
'labels' => array(
'name' => __( 'manager' ),
'singular_name' => __( 'manager' ),
'add_new' => __('Add New', 'manager'),
'add_new_item' => __('Add New manager'),
'edit_item' => __('Edit manager'),
'new_item' => __('New manager')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products'),
'supports' => array(
'title',
'thumbnail',
'comments',
'editor')
)
);
}
?>
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
No comments:
Post a Comment