Custom Search Not Consistent with Results

I figured out the answer to my own question (finally!). I’m using the NineToFive template and I guess by default there’s a limit on the number of search results that’s returned (I’m not sure if that’s a WordPress default; maybe someone can clarify that). I changed my query to this: $s = new WP_Query(array(‘s’ => … Read more

Loop get_theme_mod

There is get_them_mods() which will… Retrieve all theme modification values for the current theme. If no theme mods have been set, will return boolean false. https://codex.wordpress.org/Function_Reference/get_theme_mods It should return an array that you can loop over.

Display post category in foreach loop with category link

You are fighting with the post globals, like $post, and are not getting them set correctly. Create a proper Loop using WP_Query and use Core template tags where possible and the problem will go away. $authors_posts = new WP_Query( array( ‘author’ => 7, ‘posts_per_page’ => 6, ‘post__not_in’ => array( $post->ID ) ) ); $output=”<ul>”; while … Read more

Adding specific post category between posts in loop

You can use this as a start. This need to go into functions.php. You can use your normal loop in your template files, no need to change anything there. This will add a post from a category after post 3 and 6. Just remember to change the category name with the slug of your category. … Read more

One custom loop with condition to check child posts

The appropriately named get_children() should be what you want. if ( have_posts() ) { while ( $loop->have_posts() ) { $loop->the_post(); $args = array( ‘post_parent’ => get_the_ID(), // the ID from your loop ‘post_type’ => ‘page’, ‘posts_per_page’ => 1, // you only need to know if you have children so one is enough ‘post_status’ => ‘publish’ … Read more

Can I set my WP_Query to be a Main Query?

This is an overly complicated approach. pre_get_posts will work for any query and there are numerous ways to control when/how the callback behaves: Add and remove the callback: function dummy_action($q) { } add_action(‘pre_get_posts’,’dummy_action’); $q = new WP_Query( array( ‘post_type’ => ‘post’ ) ); remove_action(‘pre_get_posts’,’dummy_action’); Use a self-removing callback: function dummy_action($q) { remove_action(‘pre_get_posts’,’dummy_action’); } add_action(‘pre_get_posts’,’dummy_action’); $q … Read more

Show the page title on blog page

The call for the page title is outside the loop so you need to use this function instead: <?php echo get_the_title(); ?> Here is the updated code: <?php get_header(); ?> <section id=”primary-content” class=”col-md-9″> <?php echo get_the_title(); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class=”post”> <h2><a href=”https://wordpress.stackexchange.com/questions/146051/<?php the_permalink(); … Read more

Infinite blog loop

Your file is named content.php, and this line: get_template_part( ‘content’, get_post_format() ); will load the same file for posts with standard post format, causing your down-the-rabbit-hole loop.