Exclude category

To exclude a category, you need to know its ID. You can then exclude it like this (please not the minus before the ID): $args = array( ‘posts_per_page’ => 4, ‘cat’ => -the_category_id_to_put_in); The WP Query class reference has more information if you need it: http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

Accessing two databases wordpress

When enhancing WordPress functionality, always use the theme’s functions.php file (located, generally, in {WP root}/wp-content/themes/{your theme}/functions.php), or put your code into a plugin. The rules for hacking core code are similar to the rules for optimization. Don’t do it. (for experts only) Don’t do it yet.

Custom function causes a 503 error after a couple of hours

What about using the WordPress function get_ancestors(), which Returns an array containing the parents of the given object. To be exact an Array of ancestors from lowest to highest in the hierarchy We can easily create a function to return a list by using implode to do so: function wpse185971_get_ancestors_list( $object_id, $object_type=”category”, $separator=”,” ) { … Read more

Has is_archived() for sites in a multisite changed with WP 4.7?

Can you try out the following code somewhere and post the output? $mySites = wp_get_sites($args); foreach ($mySites as $blog){ print_r(get_blog_status($blog[‘blog_id’], ‘archived’)); } If this works, I suspect the code behind is_archived() used to understand blog-objects, but the function is supposed to recieve only the blog ID, not the whole object. Your code should be the … Read more

My custom get_the_excerpt() can’t get excerpt by ID

Try this one /* Change Excerpt length */ function excerpt($num, $post_id) { // removed empty default value $limit = $num+1; $excerpt = apply_filters(‘the_excerpt’, get_post_field(‘post_excerpt’, $post_id)); $excerpt = explode(‘ ‘, $excerpt, $limit); array_pop($excerpt); $excerpt = implode(” “,$excerpt).”&#8230”; echo $excerpt; } Another solution – using setup_postdata($post); and wp_reset_postdata(); function custom_get_the_excerpt($post_id) { global $post; $save_post = $post; $post … Read more

How can I modify footer when footer.php calls to another file?

You can remove_action and add_action with your own action. (https://codex.wordpress.org/Function_Reference/remove_action) In your child theme functions.php you can add this code for example : add_action(‘init’, ‘remove_talon_footer’); // Remove your parent theme actions function remove_talon_footer() { remove_action(‘talon_footer’, ‘talon_footer_sidebar’, 7); // Use same priority remove_action(‘talon_footer’, ‘talon_footer_credits’, 8); remove_action(‘talon_footer’, ‘talon_footer_menu’, 9); } /** * Footer sidebar */ function my_talon_footer_menu() … Read more