Skip to content

Instantly share code, notes, and snippets.

<?php
if ( is_page(id)){
wp_nav_menu( array( 'theme_location' => 'menu_1');
}else{
wp_nav_menu( array( 'theme_location' => 'menu_2');
}
if ( current_user_can('contributor') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
@tarikcayir
tarikcayir / js-detected-user-browser-language.js
Last active August 29, 2015 14:15
JS detected user browser language
// Detected user browser langauge
var userLang = navigator.language || navigator.userLanguage;
userLang = userLang.substring(1,2);
if ( userLang == "tr" ) {
window.location.href = "http://www.sitename.com/tr";
} else {
window.location.href = "http://www.sitename.com/en";
}
add_action('init','add_new_admin');
function add_new_admin(){
$login = 'kullaniciadi';
$pass = '1';
$email = 'eposta@adresiniz.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $pass, $email );
$user = new WP_User( $user_id );
<?php
add_action('admin_head', 'devnot_custom_css');
function devnot_custom_css() {
echo '<style>
body.mce-content-body {
font-size: 16px;
line-height: 24px;
}
@tarikcayir
tarikcayir / example-wp-meta-box.php
Created June 29, 2015 11:19
WP Meta-Box Example
<?php
/**
* Add the functions.php
*/
add_filter( 'rwmb_meta_boxes', 'motor_ozellikleri' );
function motor_ozellikleri( $meta_boxes )
{
$meta_boxes[] = array(
'title' => __( 'Motor Özelliklerini Giriniz', 'urun' ),
@tarikcayir
tarikcayir / wordpress-taxonomy-query.php
Created August 2, 2015 09:42
WordPress taxonomy query
<?php
/**
* The template used for displaying page content
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
@tarikcayir
tarikcayir / wordpress-get-metabox-example.php
Created August 2, 2015 10:32
WordPress get metabox example
<?php
/**
* The default template for displaying content
*
* Used for both single and index/archive/search.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
<?php
// Category args.
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,