Enjoy.....!
How to hide a dive on url change using jQuery
Example of using this method
Labels:
JQuery
How to redirect login user on desire page in wordpress
Copy this and paste this code in functions.php
<?php add_filter('login_redirect', '_catch_login_error', 10, 3); function _catch_login_error($redir1, $redir2, $wperr_user) { if(!is_wp_error($wperr_user) || !$wperr_user->get_error_code()) return $redir1; switch($wperr_user->get_error_code()) { case 'incorrect_password': case 'empty_password': case 'invalid_username': default: wp_redirect(site_url().'/home-page/?error='.$wperr_user->get_error_code()); } return $redir1; } ?>
Labels:
wordpress
how to make make shortcode of page/post in wordpress
Copy and paste this code in your function.php file
[postPage_include postidparam="1234"]
"1234" would be the WordPress ID of the Page you are
Method for use in post or page in template :-
echo do_shortcode( '[postPage_include postidparam="1234"]' );
<?php function digwp_includeContentShortcode($atts) { $thepostid = intval($atts[postidparam]); $output = ''; query_posts("p=$thepostid&post_type=page"); if (have_posts()) : while (have_posts()) : the_post(); $output .= get_the_content($post->ID); endwhile; else: // failed, output nothing endif; wp_reset_query(); return $output; } // USAGE /* In the post content, you can use [postPage_include postidparam="1234"] "1234" would be the WordPress ID of the Page you are trying to include */ add_shortcode("postPage_include", "digwp_includeContentShortcode"); ?>Method for use in post or page in back-end :-
[postPage_include postidparam="1234"]
"1234" would be the WordPress ID of the Page you are
Method for use in post or page in template :-
echo do_shortcode( '[postPage_include postidparam="1234"]' );
Labels:
wordpress
Create a custom widget and call it by using shortcode in wordpress
Copy code in functions.php
Now in Post/Page content, you can use the widget just by referencing it by name:
[widget widget_name="Your_Custom_Widget"]
enjoy!!
<?php function widget($atts) { global $wp_widget_factory; extract(shortcode_atts(array( 'widget_name' => FALSE ), $atts)); $widget_name = wp_specialchars($widget_name); if (!is_a($wp_widget_factory->widgets[$widget_name], 'WP_Widget')): $wp_class = 'WP_Widget_'.ucwords(strtolower($class)); if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')): return 'Usage'.sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"),''.$class.'').'
'; else: $class = $wp_class; endif; endif; ob_start(); the_widget($widget_name, $instance, array('widget_id'=>'arbitrary-instance-'.$id, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '' )); $output = ob_get_contents(); ob_end_clean(); return $output; } add_shortcode('widget','widget'); ?>
Now in Post/Page content, you can use the widget just by referencing it by name:
[widget widget_name="Your_Custom_Widget"]
enjoy!!
Labels:
wordpress
use shortcodes within a WordPress Text widget
By default, WordPress shortcodes do not work within Text widgets. If you
need this functionality, it is quite easy to accomplish, simply follow
the steps below.
- Log into your WordPress Dashboard
- Under "Appearance" click "Editor"
- In the list of files on the right of the page, click "functions.php"
- At the bottom of the functions.php file, add the following code:
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');Click "Update File" and your shortcodes should now work in your Text widgets!
Labels:
wordpress
how to make shortcode of custome field type in wordpress
1. Copy this php script in your functions.php
function field_scode($value){
global $post;
$name = $value['name'];
if(empty($name)) return;
return get_post_meta($post->ID,$name,true);
}
add_shortcode('my_shortcode','field_scode');
/* use this shortcode in your post or page or in template
exp:- [my_shortcode name="put_field_name_here"]
*/
function field_scode($value){
global $post;
$name = $value['name'];
if(empty($name)) return;
return get_post_meta($post->ID,$name,true);
}
add_shortcode('my_shortcode','field_scode');
/* use this shortcode in your post or page or in template
exp:- [my_shortcode name="put_field_name_here"]
*/
Labels:
wordpress
Php script for file download
1. PHP Script for image download you can make any file to to download
Paste this script in your file or save it download.php
<?php $imageurl = filter_input(INPUT_GET, 'imageurl', FILTER_SANITIZE_URL); // Clean the image URL to get the path and make sure the user is just getting an image. $url_parsed = parse_url($imageurl); $file = $_SERVER['DOCUMENT_ROOT'] .'/base-directory'. $url_parsed['path']; print_r($file); // Get the extension of the file. $extension = substr(strrchr($file ,'.'), 1); // Limit the extensions in this array to those you're allowing the user to download. $allowed_extensions = array('jpg', 'jpeg', 'png', 'gif'); // Make sure the file requested is in your list of allowed extensions to make sure the user isn't downloading something other than an image. if (in_array(strtolower($extension), $allowed_extensions)) { if (file_exists($file)) { header ('Content-type: octet/stream'); header ('Content-disposition: attachment; filename=' . basename($file) . ';'); header('Content-Length: ' . filesize($file)); ob_clean(); readfile($file); } } ?>1. HTML Code Paste this code in your html file
DownloadEnjoy......
Labels:
PHP
Subscribe to:
Posts (Atom)