Skip to content

Instantly share code, notes, and snippets.

@pradeepdotco
pradeepdotco / .htaccess
Created December 3, 2015 17:47
Redirect 301 old website to a new website with .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
@pradeepdotco
pradeepdotco / .htaccess
Created December 2, 2015 18:01
htaccess code to 301 redirect to new domain
# BEGIN WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.oldwordpress.com RewriteRule (.*)
http://www.newwordpress.com/$1 [R=301,L]
# END WordPress
@pradeepdotco
pradeepdotco / .htaccess
Created December 2, 2015 17:28
htaccess code default
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@pradeepdotco
pradeepdotco / .htaccess
Created December 2, 2015 17:17
htaccess code for same domain redirect
# BEGIN 301 Redirects
Redirect 301 /old-post/ http://www.yourwebsite.com/new-post/
# END 301 Redirects
@pradeepdotco
pradeepdotco / wp list categories
Created November 13, 2015 22:17
Template Tags wp list categories
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
@pradeepdotco
pradeepdotco / Associative arrays PHP WordPress
Created November 13, 2015 21:12
Associative arrays PHP WordPress
$my_array = array(
[tab]'WP' => 'somevalue',
[tab]'WP2' => 'somevalue2',
[tab]'WP3' => 'somevalue3',
[tab]'WP34' => 'somevalue3',
);
@pradeepdotco
pradeepdotco / absolute-path.php
Created November 10, 2015 23:00
Absolute Path
<?php
$p = getcwd();
echo $p;
?>
@pradeepdotco
pradeepdotco / disable-wordpress-search.php
Created November 9, 2015 22:12
Disable WordPress Search
function fb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
// to error
if ( $error == true )
$query->is_404 = true;
@pradeepdotco
pradeepdotco / Comments-Edit-Button.php
Created November 9, 2015 21:50
Comments Edit Button
<?php edit_comment_link(__('{Quick Edit}'), ''); ?>
@pradeepdotco
pradeepdotco / post-edit-button.php
Created November 9, 2015 21:49
Post Edit Button
<?php edit_post_link(__('{Quick Edit}'), ''); ?>