Using a specific template for front page only

Well first of all it depends how you are enqueing your other scripts but make sure you dont add them before the jQuery library itself has been included. There is nothing stopping you using conditional code in header.php to add scripts depending on the page that is loading, or even the template, category etc; <?php … Read more

Blog page won’t show Blog template

Based on your comment: 1) blog.php What is the file name of your blog custom page template? 2) home.php What is the file name of your front page custom page template? The answer is simple: The home.php file name is a reserved file name in the WordPress template hierarchy, and is used by the template … Read more

Organize template parts and page templates in folders in regards of template hierarchy

Page templates are special case and since WP 3.4 can be put in subfolder natively. Other than that WP mostly expects flat file structure for templates. While template hierarchy is easily adjusted (see dynamic filter in get_query_template(), pretty much only thing needed)… From personal experience – overly extensive and nested directory structure for templates makes … Read more

How to slice down index.php from a template and import from another file?

You can include other files in the way you’re describing by using get_template_part(), see: http://codex.wordpress.org/Function_Reference/get_template_part. This is intended for sections of code that you intend to reuse elsewhere on the site. However, if you’re only using these layouts (“list”, “full thumbnail”, etc.) on the home page, then it’s quite fine to put them all in … Read more

Dynamically generated URL and Content page

Firstly, don’t forget to always flush your rewrite rules by going to Settings -> Permalinks and just clicking on Save Changes Now on your problem, it seems that you’re missing an ‘&‘ in your query: $new_rules[‘^test-directory/(.*)/(.*)’] = ‘index.php?test-directory=$matches[1]&test-code=$matches[2]’; Notice the & after $matches[1] On the other hand, your ‘template_redirect’ action is not calling the correct … Read more

Change “posts per page” depending on width

A simple approach would be a solution with CSS and PHP. <?php $postcount = 1; $wp_query = new WP_Query(); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div class=”post-<?php echo $postcount ?>”> <h3><a href=”https://wordpress.stackexchange.com/questions/111019/<?php the_permalink() ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h3> <div class=”entry”> <?php the_excerpt(); ?> </div> </div> <?php $postcount++; endwhile; ?> Then you can style your website, … Read more

two active templates for one post

If you look at the function you’ll see there’s an error : function detail_rewrite_rule( $rules ) { $newrules = array(); $newrules[‘(.+?)/([^/]+)(/[0-9]+)?/detail/?$’] = ‘index.php?category_name=$matches[1]&name=$matches[2]&page=$matches[3]&detail=1’; return $newrules + $rules; } add_filter( ‘rewrite_rules_array’,’detail_rewrite_rules’ ); The callback is not the same : detail_rewrite_rule, detail_rewrite_rules. In the add_filter you have to provide the same name for function. Otherwise this won’t … Read more

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