How to create function from code?

You need to pass it at least 2 parameters, or it won’t know what to look for: <?php function custom_pagination($cat_id, $catnum) { // Start of Pagination $total_childs_query = get_categories( array( ‘parent’ => $cat_id, ‘hide_empty’ => ‘0’ )); $total_terms = count( $total_childs_query ); $pages = ceil($total_terms/$catnum); $base_url = get_term_link( $cat_id, get_query_var( ‘taxonomy’ ) ); // if … Read more

Exclude category from Tag Template

Have you tried using a normal loop in your tag template like this <?php while ( have_posts() ) : the_post() ?> //add content code or template <?php endwhile; ?> And then using the pre_get_posts filter like this function exclude_category( $query ) { if ( $query->is_tag() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-433’ ); } } … Read more

Use another author.php if different multisite subsite?

This was the solution.. // different author template */ add_filter( ‘template_include’, ‘author_template’, 99 ); function author_template( $template ) { if( !is_main_site() and is_author( ) ) { $new_template = locate_template( array( ‘other-author.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; }

How can I get WP to use templates in lower-level subfolder?

Whilst you’re correct in saying WP will only scan directories 1 level deep for templates, since 4.4 you have complete control over the theme_page_templates filter (you can now add to as well as remove from the list): add_filter( ‘theme_page_templates’, function( $templates ) { $templates[‘page-templates/another/directory/template.php’] = ‘Another Directory Template’; return $templates; });

How to remove wp_link_pages() from template

No you don’t remove it from /wp-includes/post-template.php. This is a WordPress core file and you should never edit any WordPress core file. The answer is talking about removing the call of wp_link_pages function within a template file. Which template file to edit depends on the theme and the URL you are visiting. Typically it should … Read more