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

Why my wp_enqueue_script doesnt work on some page?

Hi add this code to your Function.php and jquery-ui.js should be loaded correctly on your website. // Register Script function custom_scripts() { wp_register_script( ‘jquery-ui’, ‘/assets/js/jquery-ui.js’, false, false, true ); wp_enqueue_script( ‘jquery-ui’ ); } add_action( ‘wp_enqueue_scripts’, ‘custom_scripts’ );

Add the title of a widget as an ID – for anchor links

Yes you can add an around the title of the widget, you do this in the register_sidebar code which you would put in your functions.php add_action( ‘widgets_init’, ‘theme_register_sidebars’ ); function theme_register_sidebars() { register_sidebar( array( ‘id’ => ‘mysidebar-sidebar’, ‘name’ => __( ‘My Sidebar’, ‘themename’ ), ‘description’ => __( ‘Widgets for my sidebar’, ‘themename’ ), ‘before_widget’ => … Read more

Sort results by name & asc order on homepage

Since you only want to hook into the posts on your homepage, I think you only need something like this: <?php add_action( ‘pre_get_posts’, ‘my_change_sort_order’); function my_change_sort_order( $query ){ if ( ! is_admin() && $query->is_main_query() ) : if ( is_front_page() ) : //Set the order ASC or DESC $query->set( ‘order’, ‘ASC’ ); //Set the orderby $query->set( … Read more