Hyperlinking images on posts to permalink

If they are featured images or post Thumbnails U can add this code in functions.php to link them add_filter( ‘post_thumbnail_html’, ‘my_post_image_html’, 10, 3 ); function my_post_image_html( $html, $post_id, $post_image_id ) { $html=”<a href=”” . get_permalink( $post_id ) . ‘” title=”‘ . esc_attr( get_post_field( ‘post_title’, $post_id ) ) . ‘”>’ . $html . ‘</a>’; return $html; … Read more

Showing sidebar-2 on custom template page

you can put this code in your functions add_action( ‘init’, ‘register_my_menus’ ); function register_my_menus() { register_nav_menus( array( ‘menu-1’ => __( ‘Head’ ) ) ); } and this code, in the place you want your second menu <?php wp_nav_menu( array( ‘theme_location’ => ‘menu-1’ ) ); ?> and than, you can control your new menu, through the … Read more

How to insert a clickable and fixed background [duplicate]

Add div after body tag and apply below style. Your site start working. <div class=”fixedHeader”></div> <style type=”text/css”> .fixedHeader{ position: fixed; height: 80px; background: white url(http://www.affiliago.it/accounts/default1/banners/SKIN_BAKECA.jpg) no-repeat no-repeat center top; width: 100%; z-index: 1000; top: 0; } </style>

Generating custom URL before post is published

I think the post needs to be inserted first. This is a sample function that updates the post slug after it’s been inserted. // Update post slug $my_post[‘ID’] = $pid; $my_post_name=”post_name” . “-” . $pid; $my_post[‘post_name’] .= $my_post_name; // Update the post into the database wp_update_post( $my_post ) It’s combining the post_name with post ID … Read more

custom walker to add iconfont to wp_nav_menu

ok, I figured it out myself. instead of using the CSS class (as I cannot figure out how to filter it), I decided to use the description instead. under the lines with $attributes I have added this line: $description = ! empty( $item->description ) ? esc_attr( $item->description ) : ”; And then I added that … Read more

Redirect posts to sub domain except pages

I would do this per server configuration. Here is an example for the .htaccess: RewriteCond %{HTTP_HOST} !^blog\.example\.com$ RewriteRule (.*)\.html$ http://blog.example.com/$1.html [L,R=301] You could do this in a WordPress plugin too. Untested suggestion: add_action( ‘template_redirect’, ‘wpse_77279_redirect’ ); function wpse_77279_redirect() { if ( is_single() and ‘blog.example.com’ !== $_SERVER[‘HTTP_HOST’] and ‘post’ === get_post_type() ) { wp_redirect( ‘blog.example.com’ . … Read more