add jquery file if a certain page is included

While you can approach it with “what template is loaded”, WP isn’t engineered for such logic. Template load is result of logic processing, not the other way around. You should check out Conditional Tags and determine which logical check applies to your situation. Other than that you should be: running script-related logic on appropriate wp_enqueue_scripts … Read more

Writing less unnecessary code with WordPress

Try this function cat_loop ($key){ $fashion_cat = array( ‘category_name’ => $key, ‘posts_per_page’ => 4, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post__not_in’ => $already_posted, ‘category__not_in’ => $private_categories ); // Add the loop. } cat_loop (‘fashion’); cat_loop (‘beauty’); cat_loop (‘lifestyle’); put the loop in function which has variable for the category_name … Read more

How to replace settings in WordPress plugin from a theme

You are already pretty close. Extending your example: In your plugin put this: $default_settings = array( ‘key_one’ => 0, ‘key_two’ => 1 ); $settings = apply_filters( ‘example_filter’, $default_settings); Then a theme can change it like this: add_filter(‘example_filter’,’my_function’); function my_function($settings){ $settings[‘key_one’] = 1; return $settings; }

Show post categories

If you select both categories for the post the_category() will display both and using multiple will make the child category display the parent relationship, so you will have the parent twice. If you want to display a link to the parent category and a link to child category select only the child category for the … Read more

How to create Page templates for showing Blog posts in different layouts?

I wouldn’t use custom page templates merely for changing the layout of the blog posts index. Using page templates for the blog posts index bypasses the core handling for display of the blog posts index (which per the template hierarchy uses either home.php or index.php to render). Edit I never…said that I want to change … Read more

Custom theme won’t use search.php

Why you are using this filter code, WordPress will still use searchform.php code, without it? Further, it could be some issue with the loop code within search.php. Twentyfourteen theme looks for content-[post-format].php file. Do you have one in you theme root? get_template_part( ‘content’, get_post_format() ); try using this simplified loop in search.php … <?php if(have_posts()) … Read more

Hardcode a form in Contact Form 7 [closed]

I’ve looked for this some time ago. Best thing you can do is change the default contact form. Filter you can use: wpcf7_default_template Info can be found in contact-form-7/includes/functions.php file line 63 The filtered variable is: $template=”<p>” . __( ‘Your Name’, ‘contact-form-7’ ) . ‘ ‘ . __( ‘(required)’, ‘contact-form-7’ ) . ‘<br />’ . … Read more