Child Theme files – what is needed?

Yes you will need to enqueue parent theme styles into child theme. Adding style.css in child theme will not automatically add parent theme’s styles too. You can enqueue parent theme’s styles like this. Create a new functions.php in child theme and paste this. function enqueue_child_theme_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ ); wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array(‘parent-style’) ); … Read more

Commenter should see only his comments in wordpress

What you need to do to achieve this is to provide the second parameter of wp_list_comments(), which would be $comments and is described like this: (array) (optional) Array obtained by get_comments query. Default: The default return of get_comments. Which actually makes it clear what you need to do, which would be utilizing get_comments(). Below a … Read more

Set the background to a default image if there isn’t a specified “featured image”

I found the solution from a WordPress forum and this is what they used. Works perfect <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ” ); $image = $image[0]; ?> <?php else : $image = get_bloginfo(‘stylesheet_directory’) . ‘/lib/images/home1-1024×681.jpg’; ?> <?php endif; ?> <section id=”halfpro” style=”background-image: url(‘<?php echo $image; ?>’)” … Read more

changing behaviour of get_search_form

you don’t need to add another function to get the search form. If you want to change the look of the search form or add another items you’ll have to add the searchform.php to your theme. It could look like this: <form role=”search” method=”get” class=”search-form” action=”<?php echo home_url( “https://wordpress.stackexchange.com/” ); ?>”> <input type=”search” class=”search-field” placeholder=”Suchen … Read more

Converting HTML Template to WordPress Theme

As said, you should enqueue your style sheets like this in your functions.php in your theme: function adds_to_the_head() { // Our own unique function called adds_to_the_head wp_register_style( ‘custom-style-css’, get_stylesheet_directory_uri() . ‘/css/styles.css’,”,”, ‘screen’ ); // Register style.css wp_enqueue_style( ‘custom-style-css’ ); // Enqueue our stylesheet } add_action( ‘wp_enqueue_scripts’, ‘adds_to_the_head’ );

Custom Post Type with Templates using Meta Boxes?

I’d recommend using the template_include filter as opposed to template_redirect, as using this hook means that you don’t redirect the user but rather just present them with the template that is requierd. add_filter(‘template_include’, ‘my_custom_template_redirect’, 99); function my_custom_template_redirect($template){ global $post; if(is_single() && ‘campaign’ == get_post_type($post)){ $page_template = get_page_template(); $new_template = locate_template( array( ‘subfolder/’ . $page_template . … Read more