Skip to content

Instantly share code, notes, and snippets.

@duogeekdev
duogeekdev / Append post ID at the end of the URL for a custom post type.php
Created May 14, 2015 06:44
Append post ID at the end of the URL for a custom post type
<?php
function change_post_type_link( $link, $post = 0 ){
if ( $post->post_type == 'product' ){
return home_url( 'product/'. $post->post_name .'/'. $post->ID );
} else {
return $link;
}
}
@duogeekdev
duogeekdev / code.php
Last active January 23, 2017 19:34
Add featured image in rss feed in a wordpress site
<?php
function add_featured_image_in_rss() {
if ( function_exists( 'get_the_image' ) && ( $featured_image = get_the_image('format=array&echo=0') ) ) {
$featured_image[0] = $featured_image['url'];
} elseif ( function_exists( 'has_post_thumbnail' ) and has_post_thumbnail() ) {
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumbnail' );
} elseif ( function_exists( 'get_post_thumbnail_src' ) ) {
$featured_image = get_post_thumbnail_src();
<?php
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . 'new/path/to/wp-content' );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . 'new/path/to/wp-content' );
@duogeekdev
duogeekdev / rename-plugin-folder.php
Created May 9, 2015 22:00
Rename plugin folder
<?php
define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/new/path/to/plugins' );
define( 'WP_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/new/path/to/plugins' );
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'db_name_here');
/** MySQL database username */
define('DB_USER', 'db_user_name');
/** MySQL database password */
@duogeekdev
duogeekdev / Protect WordPress admin area.php
Created May 9, 2015 20:55
Protect WordPress admin area
<Files wp-login.php>
order deny,allow
Deny from all
Allow from xx.xxx.xxx.xxx
</Files>
<?php
define('AUTH_KEY', 'b],!QlPUie0ycv~R_qU~FL2o2kv7Ve}(oXs+QS$ynckMB[|C5hvCJv?Lt +)&[/4');
define('SECURE_AUTH_KEY', 'vAzf}:6fi2>Y;;euR2(O==|Ja$-$k!Eg)M vYp=-4lxA22SQVP+Rv(#CSN^W79c~');
define('LOGGED_IN_KEY', '!-*@/CC9{cK.q+a+v}bvTgb]:&,`QNx=udW/2Ah y.dJ 0[`XWV&OMc+<&p43~lQ');
define('NONCE_KEY', 'SODE d>js8Tu;^SAEQ6f8Oj|V1iz?[(N{P)II5Cb9|-}2C$-y`E*Kn8L#@O/,e{U');
define('AUTH_SALT', '3m07lkx1!-)97:LjkN~c6Q?|f>2_+=*QpyohH?`i=dY!Y)ksS0yZdp*I_+?nhUKF');
define('SECURE_AUTH_SALT', 'jfrx@D<GkJ+>:#W9q?u{3n)+A|/:`8j@4nA@V}7&-C}-k`N:.|{qq`6-s.:>k5^)');
define('LOGGED_IN_SALT', '.m~&d`Rh1v1_!g#w)]b-:-Hy/-g0ZQ0Ol$`BJ/u9w,cQ)?X TU~/v4kZD&8{;d]#');
define('NONCE_SALT', 'h0HtiN26c+FD;AMAuNn)G)!aDzA=F[m,&w)Rzb/eJ^bh!DV#W)oz[t;%=VjMq] /');
@duogeekdev
duogeekdev / prefix.php
Created May 9, 2015 21:19
Table prefix
<?php
$table_prefix = 'wp_';
@duogeekdev
duogeekdev / change-prefix.sql
Created May 9, 2015 21:23
Replace wordpress table prefix in mysql
// Do this for all existing tables
RENAME table `wp_posts` TO `me_posts`;
// The the following
UPDATE `me_usermeta` SET `meta_key` = REPLACE( `meta_key`, 'wp_', 'me_' );
UPDATE `me_options` SET `option_name` = 'me_user_roles' WHERE `option_name` = 'wp_user_roles';
@duogeekdev
duogeekdev / hide-version.php
Created May 9, 2015 21:29
Hide WP Version
<?php
remove_action('wp_head', 'wp_generator');