I am working in an wordpress theme.Where i have created some template part in a folder named "template_part".When i call the template part from page.php function in wordpress the styles are not working.how can i solve the problem.I am giving the codes of the template part below

<div class="tmp1_style col-md-12" >
                    $args = array('category_name'=>'খেলা', 'post_type' => 'post', 'showposts' => 5);
                    $the_query = new WP_Query( $args );
                    $count = 0;
                        if ( $the_query->have_posts() ) {
                        while ( $the_query->have_posts() ) {
                                 <h3> <?php echo the_title();?></h3>
                                <?php $count++;
                            } else {?>
                                no posts found
                            <?php }
                                /* Restore original Post Data */

i want to style the "tmp1_style" class.I am trying to style them from style.css.i want to add background image on the template part.The image file is in img folder.Now how can i solve the problem?????

  • If the styles are not working is because either your style is wrong or the template you created is not loading correctly. But having a template file in a different folder does not affect the style.css file. The style.css file is applied to every page. Easiest way to solve this is to load the page in chrome or firefox, right click, select inspect element, and then take a look at the source and the styles to see what you're missing. – gdaniel Mar 3 '14 at 4:53

Having template files in different folders has nothing to do with styles not working.

View page source and make sure the right stylesheet is loaded. If its loaded, then double check if there is any other rules thats overriding your needed rules for specific class. Try adding !important to the css definitions and see if it works.

This is how you should add stylesheets to frontend output, you need to add this code in your functions.php inside your active theme.

function my_custom_css() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );

add_action( 'wp_enqueue_scripts', 'my_custom_css' );

Hope this helps :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy