Latest Post
Tampilkan postingan dengan label wordpress. Tampilkan semua postingan
Tampilkan postingan dengan label wordpress. Tampilkan semua postingan

Add shortcode to template file in woocommerce or wordpress

Written By Unknown on Rabu, 30 Oktober 2013 | 02.20

Shortcode API, a simple set of functions for creating macro codes for use in post content. It enables plugin developers to create special kinds of content (e.g. forms, content generators) that users can attach to certain pages. For instance, the following shortcode (in the post/page content) would add a photo gallery into the page:     [gallery]

But this syntax work for only wp-admin post editor. If you want to add shortcode to your template file then you can use

<?php
        echo do_shortcode( '[shortcode_name]' );
 ?>
It will do same work as done by shortcode when it is added to post...

Warning: Cannot modify header information - headers already sent in - wordpress after activating custom plugin

Written By Unknown on Jumat, 25 Oktober 2013 | 07.10

Warning: Cannot modify header information - headers already sent by

If you got error like this after activation a new custom plugin in wordpress then you can use

error_reporting(0);    // Turn off all error reporting
  
Include this statement in every file due to which you are getiing warning . You are done , no more errors now :)

But remember if you are a developer..... you are only hiding errors ... not solving them ...
Try to solve them first ... If unable only then use this :)



Warning: Cannot modify header information - headers already sent in - wordpress after activating custom plugin

Redirect to a url after login in wordpress/woocommerce

Written By Unknown on Selasa, 15 Oktober 2013 | 00.53


By default you are redirected to my account page in  wordpress/woocommerce after login.
If you want to redirect to some other url use the code below:

add_filter('woocommerce_login_redirect', 'ras_login_redirect');

function ras_login_redirect( $redirect_to ) {
     $redirect_to = "www.google.com";    

     return $redirect_to;
}


If you provide some value to $redirect_to you will be redirected to that url otherwise
you will be redirected to my account as due to default settings in wordpress.

Update value of $wp_session['session_name'] in woocommerce/wordpress

Written By Unknown on Minggu, 13 Oktober 2013 | 23.10

$wp_session = WP_Session::get_instance();
 is method to create your own  session in woocommerce/wordpress.
You can use $wp_session['session_name'] on any file in woocommerce/wordpress
after creating but if you want to change its value you need to first convert this object to array.

For creating array use
$temp = current((array)$wp_session['session_name']);

$temp return you the array / value assigned to $wp_session['session_name']...
Now use or edit $temp as your need and after use assign this array again to $wp_session['session_name']
using

unset ($wp_session['session_name']);
$wp_session['session_name']=$temp;

Example :
$wp_session = WP_Session::get_instance();
$temp = current((array)$wp_session['session_name']);

/***

Work with the array

***/
unset ($wp_session['session_name']);
$wp_session['session_name']=$temp;

Convert $wp_session object to array

$wp_session = WP_Session::get_instance();
 is method to create your own  session in woocommerce/wordpress.
You can use $wp_session['session_name'] on any file in woocommerce/wordpress
after creating but if you want to change its value you need to first convert this object to array.

For creating array use
$temp = current((array)$wp_session['session_name']);

$temp return you the array / value assigned to $wp_session['session_name']...
Now use or edit $temp as your need and after use assign this array again to $wp_session['session_name']
using

unset ($wp_session['session_name']);
$wp_session['session_name']=$temp;

Example :
$wp_session = WP_Session::get_instance();
$temp = current((array)$wp_session['session_name']);

/***

Work with the array

***/
unset ($wp_session['session_name']);
$wp_session['session_name']=$temp;

Use $_SESSION in WordPress/Woocommerce

By default you cannot create your $_SESSION in WordPress/Woocommerce.
The information in $_SESSION remain in only those files on which it is created.
You cant access $_SESSION on  other file.

So, for creating your own session variable you need to install
WP Session Manager plugin.To download you can visit

http://wordpress.org/plugins/wp-session-manager/

And to use the $_SESSION you need to first create session object.
To create object use below line.

$wp_session = WP_Session::get_instance();

and to set value use

$wp_session['session_name']=array('one'=>'1','two'=>'2');
or
$wp_session['session_name']="Your value";


Note: You have to first create session object on every file where you wish to use $wp_session object.

FUNCTION.PHP file versus PLUGIN in wordpress

Written By Unknown on Senin, 07 Oktober 2013 | 03.34

FUNCTION.PHP file versus PLUGIN in wordpress

If you have ever played  with a theme, you will know it has a functions.php file, which enables you to build plugin-like functionality into your theme.If we have this functions.php file,what is  the point of a use of plugin ?
 
Where should we use plugin and where should we use function.php file ?

Basically it all depends on your need.
Both do the same work , but the main difference is that a plugin’s functionality persists regardless of what theme you have enabled, whereas any changes you have made in functions.php will stop working once you switch themes.
Also, grouping related functionality into a plugin is often more convenient than leaving a mass of code in functions.php.
So it will be a good idea to use plugin if you want to use same code with different themes and different projects.

Media upload error in wordpress after installation of customized plugin

Written By Unknown on Kamis, 03 Oktober 2013 | 06.37

Media upload error in wordpress after installation of customized plugin
 
After installation of custom plugin in wordpress sometimes error occurs while media upload.

The reason is you have may be you have included '$' in js of plugin(replace $ with jQuery)  or might be you have added js in plugin_name.php file. 

      



Media upload error in wordpress after installation of customized plugin



To correct the error include your js of plugin in separate js file and put this file in plugin_name folder with plugin_name.php file.

And to use this js in plugin add the below function in plugin file.

function my_scripts_method() {
    wp_enqueue_script(
        'plugin_name',
        plugins_url() . '/plugin_name/plugin_name.js',
        array( 'jquery' )
    );
}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );




Hope this will solve your problem :)


Could not create directory. /opt/lampp/htdocs/wordpress-test/wp-content/upgrade(Theme installation problem in wordpress)

Written By Unknown on Selasa, 24 September 2013 | 23.53

Could not create directory. /opt/lampp/htdocs/wordpress-test/wp-content/upgrade

 Could not create directory. /opt/lampp/htdocs/wordpress-test/wp-content/upgrade

This error occur when you try to install some new theme on wordpress .
And your wp-content is not writable.





To correct this error

Change permissions on the /wp-content directory to 0775
 

if not work Change permissions on the /wp-content directory to 0777.

And dont forget to restore your permission after work is done as security measure.

Fatal error : Call to undefined function add_menu_page()

Written By Unknown on Senin, 23 September 2013 | 23.58

Fatal error : Call to undefined function add_menu_page()

If you want to add menu to admin section of wordpress through custom plugin and you got
"Fatal error : Call to undefined function add_menu_page() " error.

Then reason for error might be there is no add_action function found in plugin

Try this code to solve this error in your plugin file.

<?php

/*
Plugin Name: Myplugin

Description:
Version: 2.5.324
Author: Amit kumar


*/
add_action('admin_menu', 'test');

function test(){
    add_menu_page(__('My Menu Page'), __('My Menu'), 'edit_themes', 'my_new_menu', 'my_test_function', '', 7);
}

function my_test_function(){
    echo "hello world .. !!";
}
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger