0

I do not have any cache plugins, css is

    #featured { border-bottom: 1px solid #ffffff; background: #000000; height: 300px; overflow: hidden; }
div.slide { height: 300px; position: relative; }
    div.overlay, div.top-overlay { background:url("images/dropshadow.png") repeat-x bottom left; bottom:0; height:22px; left:0; position:absolute; width:100%; }
    div.top-overlay { background:url("images/top-overlay.png") repeat-x bottom left; top: 0px; height: 43px; }
    .slide .description { background:url("images/overlay.png") no-repeat scroll 0 0 transparent; float:right; height:276px; margin-top:6px; padding:18px 68px 0 50px; width:342px; }
        .description h2.title { font-weight: bold; font-size: 36px; padding-top:3px; }
            .description h2.title a { color: #ffffff; text-shadow: 2px 2px 2px #000000; }
                .description h2.title a:hover { color: #eeeeee; text-decoration: none; }
        .description p.tagline { font-size: 14px; font-family: Georgia, serif; font-style: italic; color: #4f4f4f; padding: 7px 0px 4px; }
            .description p.tagline a { color: #4f4f4f; }
                .description p.tagline a:hover { color: #7c7c7c; text-decoration: none; }
        .description p { line-height: 19px; }

        .slide a.readmore { background:url(images/featured-readmore-right.png) no-repeat scroll right bottom; display:block; float:left; height:31px; line-height:32px; padding-right:11px; color: #ffffff; text-shadow: 1px 1px 1px #0080bd; margin-top:8px; }
            .slide a.readmore span { background:url(images/featured-readmore-left.png) no-repeat; display:block; padding: 0px 4px 0px 15px; }

  a#prevlink, a#nextlink { position:absolute; bottom:-2px; right:0; height: 40px; text-         indent: -9999px; display: block; z-index: 1000; }
  a#prevlink { right: 80px; background: url(images/arrow-left.png) no-repeat; width: 81px; }
  a#nextlink { width: 80px; background: url(images/arrow-right.png) no-repeat; }

Ofcourse nothing is wrong with the code. It just seems to be im missing a function which updates the web cache. The code is how its supposed to be but when my browser reads it off my webpage I get this link wp-content/themes/TheSource/style.css:284 rather than wp-content/themes/TheSource/style.css which is my main problem as I can't edit simple images off my slider to do what I want. I know that this happened to me with a widget i looked on google and found a function to add becuase I was getting something like wp-content/themes/TheSource/style.css?ver:248 before and now it took off the ?ver but I need something that will allow me to update my theme so that I can customize it.

  • Usually you will have a better chance to get the answers you're looking for, and get them faster, by making your code short and to the point. Try removing any code that isn't directly involved in the part where your problem occurs, or try making a simplified analogous code that exhibits the same problem for you. – Joeytje50 Jan 27 '14 at 03:16

1 Answers1

2

During development process you can append the following code to your CSS:

/wp-content/themes/TheSource/style.css?ver:248&t=<?php echo time(); ?>

It generates different timestamp on every page reload and this way it avoids browser caching.

I highly recommend that you remove this part once you put the website live! Then if the site is live and you need to adjust the CSS, you can manually change the version (+1) to force all new page reloads use the new styles:

/wp-content/themes/TheSource/style.css?ver=249

...And same applies when you want to change images in the CSS, i.e:

.class123 {
    background-image: url(images/slider1.jpg?v=2);
}

Alternatively, if it's confirmed I understood you correctly and it's a browser caching issue, you can use a plugin for your browser, which prevents the caching (for Firefox - web developer toolbar).

EDIT 1: Avoid browser caching of CSS (and JS) files in Wordpress (usually used during theme development or after changes in the css/js files)

Goals: 1. Remove the CSS (and JS) 'ver' parameter from the query string. (you already have this functionality in your theme) 2. Add custom 'ver' (v) parameter to the CSS and JS files. 3. Add custom 'timestamp' (t) parameter during the development process to avoid browser caching on each page reload. (DEV mode only)

Here is a modified code from your theme, which removes the version from the CSS (and JS if needed), and adds specific parameters!

/* Removes the 'ver' parameter from the query string of the CSS (and JS) */
function remove_cssjs_ver( $src ) {
    // Goal 1 - Remove the CSS (and JS) 'ver' parameter from the query string. (you already have this functionality in your theme)
    if( strpos( $src, '?ver=' ) ) {
        $src = remove_query_arg( 'ver', $src );
    }
    // Goal 2 - Add custom 'ver' (v) parameter to the CSS and JS files. (useful for Live sites, when you change the styles or functionalities)
    $src = add_query_arg( 'v', '25', $src ); // you can use increment by 1 after every change
    // Goal 3 - Add custom 'timestamp' (t) parameter during the development process to avoid browser caching on each page reload. (DEV mode only)
    $src = add_query_arg( 't', time(), $src ); // recommended to be used only during the development process as it avoids browser caching on every page reload

    return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 999, 1 );
// add_filter( 'script_loader_src', 'remove_cssjs_ver', 999, 1); // optional - apply the same to JS files

Please note that the above code is untested, but should work. You can remove (or comment) the goals you dont need.

Some links for reference: add_query_arg, remove_query_arg, add_filter

I also modified your functions.php file to a new version: http://pastebin.com/SLA7JkEZ

The change are: fixed incorrectly nested if: if ( ! function_exists( 'et_list_pings' ) ){... You was placed the "function remove_cssjs_ver()" declaration inside this IF, which may work in your case, but it's not correct! I also fixed the last argument (from 2 to 1) of the add_filter function as you have only 1 argument in the remove_cssjs_ver() function.

And a personal note to you - I think you should change the question title to something like: Disable browser cache for CSS during Wordpress theme development and clear the cache after every change to theme styles.

Let me know if the above works for you or not!

Minister
  • 1,198
  • 2
  • 10
  • 18
  • I think this is exactly what I need but where would i put the code o.o in what folder? – user3207866 Jan 17 '14 at 21:09
  • You can try the alternative solution I've just added to my post. On your question - I need some more info... it would be good to look at the source, could you please provide temporary link to the theme (a ZIP)? – Minister Jan 17 '14 at 21:12
  • here m8 i cn just add u on skyp n screen share – user3207866 Jan 17 '14 at 21:19
  • tell me if u r up for it – user3207866 Jan 17 '14 at 21:20
  • Well, I think it could be not enough as it could take much time and also I'm not sure the community accepts it (most probably not). You and me can get penalty to doing it, so it would be better to either: give us a link or give us more details about your theme (is it a free theme, then give us the name; if not we may need the contents of the functions.php file - [click here for a site where to post the PHP contents](http://stackoverflow.com/questions/4616159/is-there-a-php-sandbox-something-like-jsfiddle-is-to-js) ) – Minister Jan 17 '14 at 21:28
  • I just found out that my friend went on his phone and had never been on my site and the yupdate shows fine for him. On the other hand me and my other friend who was on my site before cannot see the update. I will post the function.php below – user3207866 Jan 17 '14 at 22:14
  • Could you post the URL of your site if it's available on the net? It could help me investigate if there is need for any change or it works just as needed. In the meantime I'll investigate the functions.php file you posted above. – Minister Jan 18 '14 at 07:34
  • I've just corrected my answer above and added some code for achieving different goals. I hope it's all you need on this topic. Please also check the note for changing the question title, so it be much more relevant to my answer! – Minister Jan 18 '14 at 08:46