Templating of a specific post ID

You have to follow this file name structure: single-{post-type}-{slug}.php If you have a post names “Hello World” and the slug of post is hello-world then the template name will be single-post-hello-world.php Update: There is no default way to use id in template name. But you might try this snipped: <?php add_filter( ‘single_template’, ‘load_post_template_by_id’ ); function … Read more

Display “large” image size and show caption in attachment page

I’ve tested the following and it works for me. This uses the image’s Title for the ‘alt’ text and displays the image’s caption below the image itself. Use this in content-attachment.php, replacing the current the_content function: $attachment_id = get_the_ID(); // If this attachment is an Image, show the large size if ( wp_attachment_is_image( $attachment_id ) … Read more

Custom excerpt function re-factoring

I’d simply set a flag as second input argument for the function: function new_wp_trim_excerpt( $text, $case=”plain” ) { switch ( $case ) { default : case ‘plain’ : // do stuff – your function so far break; case ‘image’ : break; } } Notes: Avoid names like class=”moarplz”. It’s hard to read for others and … Read more

Display a specific dynamic sidebar widgets on a specific page

I think what you might need is simply to run register_sidebar() in an ‘widgets_init’ hook. The TwentyTen theme has examples for register_sidebar() in its functions.php file, but here’s what it might look like: add_action( ‘widgets_init’, ‘twentyten_widgets_init’ ); function twentyten_widgets_init() { register_sidebar( array( ‘name’ => __( ‘News Sidebar’, ‘yoursite’ ), ‘id’ => ‘sidebar-news’, ‘description’ => __( … Read more

Why are theme templates organized as multiple point of entry PHP files instead of reusing your theme’s index.php?

Theme template files are organized in this way because of the WordPress Template Hierarchy. Since all primary template files eventually fallback to index.php, it is certainly possible to use only the index.php primary template file. There are advantages and disadvantages to using either method. Generally speaking, the usefulness/efficiency of defining template files is inversely proportional … Read more

More than one search results page template

You could make a page template http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates And then you could post some data via $_GET /search2/?search=xxx to that page and do a custom wp_query where you use ‘s=” . $_GET[“search’] http://codex.wordpress.org/Class_Reference/WP_Query Something like this: $args = array( ‘s’ => $_GET[‘search’] ); $the_query = new WP_Query( $args ); // The Loop while ( $the_query->have_posts() ) … Read more

Single post as homepage?

Not sure if it is the most elegant way but the easiest is probably to create a shortcode that displays a single page, and then set that page to display as the front page. e.g. http://wordpress.org/extend/plugins/post-content-shortcodes/

How do I create a separate page for each author?

Create an author.php template by copying your themes archive template to start with. Then you can modify it as you wish. WordPress will use this author template for every author on your site automatically As an example visit damien.co/author/damiensaunders Note you may have to change your authors names as Damien (space) Saunders doesn’t become damien%20saunders … Read more

Custom page template not working

I think you’re muddling up the Template Hierarchy, so make sure to start by reading that. page-blog-page.php is for a page with the slug “blog-page.” If you’re using a page template, then you should name it something outside of the template hierarchy-reserved name spaces (e.g. page-{slug}, etc.) such as template-swapnesh.php. Also, WordPress has the blog … Read more

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