2 Loops, Only Displaying 1 Loop in Both Loops

You can’t add the pre_get_posts action right before the loop. You HAVE to do it in functions.php. It has to be set before the site actually queries the db to set up the loop which happens before your template file is loaded. What you are doing is looping through the exact same query twice, because … Read more

Word Count Function Preventing Permalink Editing

I put the script in a external file // Excerpt word count function excerpt_count_js(){ wp_enqueue_script( ‘excerpt-word-count’, plugins_url( ‘excerpt_word_count.js’, __FILE__ ), array( ‘jquery’ ), false, true ); } And modified the script a bit jQuery(document).ready( function($){ $(“#postexcerpt .handlediv”) .after(“<div style=\”position:absolute;top:2px;right:5px;color:#666;\”><small>Excerpt length: </small><input type=\”text\” value=\”0\” maxlength=\”3\” size=\”3\” id=\”excerpt_counter\” readonly=\”\” style=\”background:#fff;\”> <small>word(s).</small></div>”); $(“#excerpt_counter”).val($(“#excerpt”).val().split(/\S+\b[\s,\.\’-:;]*/).length – 1); $(“#excerpt”).keyup( function() { … Read more

Menu fallback “menu_class” rendering a “div” instead of a “ul”

First, I think you’re confusing the wp_nav_menu() args. The ‘menu_class’ parameter defines the class added to the menu element, which by default is <ul>, as per the ‘items_wrap’ parameter. The default ‘menu_class’ is ‘menu’, which results in <ul class=”menu”>. The real issue is actually the fallback_cb – the callback used when no menu is defined … Read more

How to add content at the end of posts?

You can simply use get_field that returns the field instead of the_field that echo it. function custom_content_filter_the_content( $content ) { if ( function_exists(‘get_field’) ) { $content .= ‘<span class=”custom_fds”>’ . get_field(‘field1’) . ‘</span>’; } return $content; } add_filter( ‘the_content’, ‘custom_content_filter_the_content’ );

Get current page_id before loop, in functions.php

I’m pretty sure you try to use this conditional tags to early, so they don’t work. From Codex: Warning: You can only use conditional query tags after the posts_selection action hook in WordPress (the wp action hook is the first one through which you can use these conditionals). For themes, this means the conditional tag … Read more

Load parent theme files before child theme functions.php

The functions.php file executes at plugins_loaded, with the Child Theme functions.php executing before the Parent Theme functions.php. That means that, in order to load functional sub-files in the Child Theme after the Parent Theme functions.php executes, you simply need to hook your include() calls after plugins_loaded. A usually safe action for such purposes is after_setup_theme: … Read more