Cannot implement byline into posts container in single.php

On single.php, as I mentioned earlier, there is no loop to put the PHP code into. If your theme follows WordPress standards, there will be a loop. You’ll likely find it in the Template Part files that are being called in your If/Then statement. Look for the following files under [theme folder]\templates\: template_single_multi.php template_single.php Right … Read more

Category ID returns as ‘0’?

Answered my own question, although not exactly how I had originally intended. <?php $cat_name = get_theme_mod( ‘cat_1’ ); $cat_name = str_replace(‘ ‘,’-‘,$cat_name); ?> <?php query_posts(‘category_name=” . $cat_name); ?> So instead of trying to convert the category name to the category id, this seems to convert the category name to the category slug. I can test … Read more

Run “the loop” in a random order

As I understood, you want the same results but randomize their order. So, you need to shuffle that results. That is quite simple using shuflle() PHP function. But that function needs arrays, not objects. You could convert the object from WP_Query to an array or, I think better, use get_posts() instead of WP_Query. $args = … Read more

Filter existing hook using parameter and foreach loop

As per the suggestion of Milo who pointed me to the right direction, this problem has now been resolved. All I had to do was this… add_action( ‘init’, ‘get_custom_tax’ ); function get_custom_tax() { $args = array( ‘public’ => true, ‘_builtin’ => false ); $taxonomies = get_taxonomies( $args, ‘names’, ‘and’ ); foreach($taxonomies as $key => $taxonomy) … Read more

get_terms() parent, child and grandchild

Since this is for a taxonomy archive, you can just use get_queried_object() and the parent and depth argument in wp_list_categories(): $term = get_queried_object(); $list = wp_list_categories( array( ‘orderby’ => ‘name’, ‘taxonomy’ => $term->taxonomy, ‘parent’ => $term->term_id, ‘title_li’ => ”, ‘depth’ => 1, ‘echo’ => false, )); if ( $list ) { echo “<ul>$list</ul>”; } else … Read more

Rendering pages

The WordPress template hierarchy is your friend. https://developer.wordpress.org/themes/basics/template-hierarchy/ This provides a very detailed flow for how WP determines which template to load. If you are ever uncertain about which template is loading, this little function is handy. Paste in your theme’s functions.php and it will display the template used at the bottom of the page. … Read more