Using pre_get_posts to filter by custom fields while using static front page
Using pre_get_posts to filter by custom fields while using static front page
Using pre_get_posts to filter by custom fields while using static front page
You can check for is_home() and is_front_page() inside of your filter: add_filter( ‘the_content’, function( $content ) { if ( ! is_home() and ! is_front_page() ) return $content; return ‘Home, sweet home!<br>’ . $content; });
Turns out since the plugin output in the footer I just had to reset the query: wp_reset_query();
i did find my answer here : http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/ add_filter( ‘wp_nav_menu_items’, ‘your_custom_menu_item’, 10, 2 ); function your_custom_menu_item ( $items, $args ) { if (is_single() && $args->theme_location == ‘primary’) { $items .= ‘<li>Show whatever</li>’; } return $items; }
Only homepage working correctly, 404 error on everything else
There are ways to write the code more efficiently, though not necessarily WordPress-specific. Only pass necessary args to your get_posts() calls The only critical args you need are posts_per_page and category; you can omit the rest Make an array of category IDs, and loop through the array Loop through an array of category IDs, so … Read more
The issue is not in how your site is coded or operated, but in how Google decides to show their search results. When the homepage is pulled up, sometimes they’ll show recent posts below it, but often won’t show your author information next to it, because the same author has already been shown above. So … Read more
Since you have a static page as the front page, use is_front_page() instead of is_home() in the condition.
Try !is_front_page() Or is_front_page() But it depends on what the function is.
There are a few issues here, but I’m not sure that any one directly is your problem. First, you need to be more specific in your pre_get_posts callback conditional, to ensure you’re targeting only the main query. Second, you need to clarify the post type you’re intending to show. Third – and the one that … Read more