0

This is my CSS code:

  text-align: center;
  text-decoration: none;
}

div#grow:hover
{
        -webkit-transform: scale(1.3);
        -ms-transform: scale(1.3);
        transform: scale(1.3);
    } 

This is my PHP code:

$posts = get_posts($args);
        foreach ($posts as $post) :
            ?>

            <div class="txtClass" id="grow">
                <a href="#0" class="txtClass">
                    <span >"<?php echo apply_filters( 'the_title', $post->post_title ); ?>"</span>
                </a>
            </div>

            <?php 
        endforeach;

This is how I include the CSS:


function dynamic_list_add_scripts(){
    // Add main CSS
    wp_enqueue_style("dla-main-style", plugins_url(). "/dynamic_post_list/css/style.css", array(), null, true);

    // Add main JS
    wp_enqueue_script("dla-main-script", plugins_url(). "/dynamic_post_list/js/main.js");
}

add_action('wp_enqueue_scripts', 'dynamic_list_add_scripts');

What I did to debug it:

  1. I make sure the js file got loaded (added console.log and I see the printing)

  2. I see in the html the line: <link rel="stylesheet" id="dla-main-style-css" href="https:/xxxxxxxxxxxxx.com/wp-content/plugins/dynamic_post_list/css/dla-main-style.min.css" type="text/css" media="1"> so I know that the css is in the page.

  3. Check in the network tab, I see the above file actually downloaded.

  4. I checked what is the code rendered to the html:

                <a href="#0" class="txtClass">
                    <span>"Title 5"</span>
                </a>
            </div>

then I checked the css + html code i codepen it works there.

What I do rung? why the code doesn't use my CSS?

2
  • Have you tried a hard refresh? – vancoder Mar 22 at 21:27
  • Yes I tried, didn't solve the issue @vancoder – josh revenue Mar 22 at 21:29

Your Answer

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

Browse other questions tagged or ask your own question.