How to read individual user’s directory and display content to that specific user?

First an observation, using $upload_dir.’/USER_PHOTOS’.$user->user_login may lead to a mess of folders in wp-content/. I suggest wp-content/user-photos/user-login/. And the following example considers it this way. In your case, you already have the menu item, for completeness this is the submenu used for development: add_action( ‘admin_menu’, ‘wpse_75873_folder_menu’ ); function wpse_75873_folder_menu() { add_media_page( ‘User Photos Media’, ‘User … Read more

Displaying a widget in sidebar only when no other widgets rendered?

I not 100% clear what your question is so hopefully this can point you in the right direction for conditional widgets. I will give you 3 options. 1. is_active_widget checks if widgets are active based in the widget ID. http://codex.wordpress.org/Function_Reference/is_active_widget 2. Using is_active_sidebar and creating more sidebars usually gives you better control over widget output. … Read more

Theme settings default, strange behavior before first save

Don’t rely on the options ever getting saved. Better is for the Theme to function normally, whether or not the user ever visits the Theme Settings page. First step is to define a function to return your option defaults, either: Define them in the function, and then reference that function in your option parameters array … Read more

How to show single post page as home page

It depends on what theme you use as they are not coded the same. Use pre_get_posts or the reading settings and the_content() rather than the_excerpt() in your loop. function wpsites_home_page_limit( $query ) { if ( $query->is_home() && $query->is_main_query() && !is_admin() ) { $query->set( ‘posts_per_page’, ‘1’ ); } } add_action( ‘pre_get_posts’, ‘wpsites_home_page_limit’ ); Or you could … Read more

Globally register styles but enqueue them selectively

If you want the stylesheets registered in the backend, use the admin_enqueue_scripts action. function wp94156_register_styles() { wp_register_style( ‘your-stylesheet’, get_stylesheet_directory_uri() . ‘/your-stylesheet.css’, $deps, // optional $version // optional ); // since you only want it registered, we won’t enqueue it } add_action( ‘admin_enqueue_scripts’, ‘wp94156_register_styles’ );

Plugin Handle URL With Custom Theme

Here’s a slimmed-down version of what I usually do. Replace wpse100645 with whatever you want, but be respectful of the fact that you don’t want to interfere with a site’s content. <?php /** * Create a custom path and process code when it gets triggered * * @author Matthew Boynes */ if ( !class_exists( ‘WPSE_100645_Custom_Page’ … Read more

Get term name and term parent into custom post type permalink

I solved this issue by the following codes where you need to define “rewrite” argument as follows register_taxonomy( ‘map_categories’, ‘map’, array( ‘hierarchical’ => true, ‘label’ => ‘Catégories’, ‘query_var’ => true, ‘rewrite’ => array(‘slug’=>’commerce/artisans’,’with_front’=>false, ‘hierarchical’ => true) ) ); You need to understand that ‘hierarchical’ in rewrite actually solve your purpose. After the update in codes … Read more

Create more than one section in Theme Customizer

The hook customize_register is for include all your custom settings to the default core settings. Your code is a good start, Hook, there init a function, there include all settings, and sections. But you register 2 section areas with the same ID; there is wrong. If you will create two different sections on the customizer, … Read more