Filter the blog title displayed in the header

Remove that filter/function and apply your markup in the PHP template/page file. If you need help post where you output the title. CLASS Here is how I might set this up using a class: if ( ! class_exists( ‘ThemeCustomizations’ ) ) { class ThemeCustomizations { static $inBody = false; public static function set_in_body_true() { static::$inBody … Read more

How to remove html comment from source?

Here’s a quick way to remove all comments using output buffering and preg_replace. We hook in before WordPress starts outputting the HTML to start the buffer. Then we hook in after WordPress stops outputting the HTML to get the buffer and strip the HTML comment tags from the content. This code would ideally be in … Read more

Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out

It seems that the OP have managed to solve his/her problem by doing this, which can be found at Different menus for logged-in users. if ( is_user_logged_in() ) { wp_nav_menu( array( ‘theme_location’ => ‘logged-in-menu’ ) ); } else { wp_nav_menu( array( ‘theme_location’ => ‘logged-out-menu’ ) ); } The more shorter way to achieve that is … Read more

How to make sure that only one wp_cron() runs at a time?

Yes, it is possible… And to be honest, it’s often very important to do this… WP Scheduler sometimes tends to cause problems, when cron tasks are long… So how I solve this problem? I use Transients API to implement semaphores… Here’s the code: if ( ! wp_next_scheduled( ‘my_task_hook’ ) ) { wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ … Read more

How to reduce the database query-es

You can try this version with WP_Query() called only once: <?php $args=array( ‘post_type’ => ‘stiri’, ‘posts_per_page’ => 5, ‘taxonomy’ => ‘stire’, ‘stire’ => ‘articole-speciale’ ); $recentPosts = new WP_Query($args); ?> <div id=”featured” > <ul class=”ui-tabs-nav”> <?php $i=0; while ($recentPosts->have_posts()) : $recentPosts->the_post(); $i++;?> <li class=”ui-tabs-nav-item ui-tabs-selected” id=”nav-fragment-<?php echo $i;?>”> <a href=”#fragment-<?php echo $i;?>”><img src=”/scripts/timthumb.php?src=<?php the_field(‘imagine_stire’); ?>&amp;h=50&amp;w=80&amp;zc=1″ … Read more

How to show only parents subpages of current page item in vertical menu?

Finally, I solved it myself. Here is the solution: In functions.php: function show_all_children($parent_id, $post_id, $current_level) { $top_parents = array(); $top_parents = get_post_ancestors($post_id); $top_parents[] = $post_id; $children = get_posts( array( ‘post_type’ => ‘page’ , ‘posts_per_page’ => -1 , ‘post_parent’ => $parent_id , ‘order_by’ => ‘title’ , ‘order’ => ‘ASC’ )); if (empty($children)) return; echo ‘<ul class=”children … Read more