Change directory where get_header(), get_footer() and get_sidebar() look for templates

Simple solution, use get_template_part(). For example: get_template_part( ‘partials/footer’ ); Which would get the footer.php inside the partials/ directory. Another example: get_template_part( ‘partials/footer’, ‘home’ ); Which would get the footer-home.php inside the partials/ directory. One more example: get_template_part( ‘partials/footer/blog’ ); Which would get the blog.php inside the partials/footer/ directory.

Template part vs Sidebar (differences)

The get_sidebar($name); function loads sidebar template file sidebar-{$name}.php if no name in the prentacies is specified it loads the sidebar.php file. get_sidebar() and get_template_part() are almost identical, at the end they call locate_template() function that take care of loading from files. The only difference is the hook fired. If you use get_sidebar() for all your … Read more

Adding content to sidebars

Add a meta box to the post editor, similar to the excerpt meta box, and get the content of the meta box in your sidebar. If you want to reuse the same text on different pages create a custom post type sidenotes and add a meta box with a select field to let the author … Read more

customizing recent posts

Inside your post loop: <div class=”recent-post”> <div class=”thumbnail”> <?php if(has_post_thumbnail()) { the_post_thumbnail(); } else { // show a default image if no featured image is specified echo ‘<img src=”‘.get_bloginfo(“template_url”).’/images/img-default.png” />’; } ?> </div> <div class=”title”> <a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a> </div> </div> float the thumbnail div to the left and give the title div … Read more

How to insert widget areas specific to certain pages (or posts, etc.)?

Use Conditional Tags to show content only if a certain condition is met. In your case, you’re probably looking to use is_front_page(). <aside> <ul> <?php if ( function_exists( ‘dynamic_sidebar’ ) ) { if ( is_front_page() ) { if ( ! dynamic_sidebar( ‘frontpage-widget-area’ ) ) { echo ‘<li>No sidebars for the frontpage.</li>’; // some default output … Read more

How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?

Changing the default widget would be pretty complicated. However, you can write your own shortcode and function to get your desired list. I’m guessing you want an unordered list in your widget? Put this in your theme’s functions.php: add_shortcode(‘archive_by_year_and_month’,’get_archive_by_year_and_month’); function get_archive_by_year_and_month($atts=array()){ global $wpdb; $years = $wpdb->get_col(“SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” ORDER … Read more

Specific and Different Ads for each Post?

Hi @ewakened: The simplest solution would be to have them upload the ads as photos using the media features in WordPress and then to have them add custom field called “Advertisement” with the URL to the ad copied from the media module, and a custom field called and “Ad URL” to link to the advertiser’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)