Hiding Google Analytics code based on theme options

Take the GA code from your header and wrap it in a function hooked to wp_head; function __analytics_head() { $options = get_option( ‘themename_theme_options’ ); if ( !empty( $options[‘analytics’] ) ) : ?> <script type=”text/javascript”> var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘<?php echo esc_js( $options[‘analytics’] ) ; ?>’]); _gaq.push([‘_trackPageview’]); (function() { var ga = document.createElement(‘script’); … Read more

How to get child category list post in one template?

get the child categories, using get_categories(); then loop through them with a foreach loop, using WP_Query() : <?php $cats = get_categories(‘child_of=”.get_query_var(“cat’)); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 3, // max number of post per category ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : echo ‘<h3>’.$cat->name.'</h3>’; while ($my_query->have_posts()) : … Read more

Help with url rewrite

The PHP code is not enough, you need to edit your .htaccess file correspondingly. (You can do this with $wp_rewrite->mod_rewrite_rules(); somehow, or edit it manually.) However, be aware that URL rewriting is complicated stuff – are you sure you need it? If you are using pretty permalinks for posts/pages, chances are this will bork it … Read more

Attempting to filter posts using get_terms

Have you tried out isotope? I am working on a project that needs a similar function. So far it’s the closest I’ve found that will sort/filter posts. The link – http://isotope.metafizzy.co/ Here’s some questions I had about implementing it with wordpress, and was able to do so to certain extent. It can help get you … Read more

File permissions for wp-minify plugin

toscho is right. So you could probably give a try to another plugin. The Better WordPress Minify. This one also uses a folder inside the plugin’s folder, BUT. You can change the folder and place it elsewhere. Please have a look at Advanced Customization. screenshot http://s.wordpress.org/extend/plugins/bwp-minify/screenshot-1.gif We have been using it without a problem.

How do I return an image from a script

Fatal error: Call to undefined function __() in /homepages/5/d367772185/htdocs/rodandfly/wp-admin/includes/file.php on line 13 Where is your code? file.php is expecting __() to be defined which it should be if your loading it from within an activated plugin. The best way to do what your trying to do is use either media_handle_sidelaod() or media_sideload_image() which will cause … Read more