[Plugin: Background Manager] Override getOverrideID
-
I would like to overide the function, without writing to de plugin it selft,
Why: Because in my homepage I show the lastest post, and i what to show its background, instead of the default one.
protected function getOverrideID($meta, $orig_data) { global $post, $wp_query; $id = false; // Is this page being used as the post_as_page? if ($wp_query->is_posts_page) $id = (isset($wp_query->query_vars['page_id']) && $wp_query->query_vars['page_id']) ? $wp_query->query_vars['page_id'] : $wp_query->queried_object_id; // Otherwise, if it's just a regular page/post or the home if (!$id && is_singular()){ $id = $post->ID; } // Still nothing, then don't bother if (!$id) return $orig_data; $post_specific_data = get_post_meta($id, $meta, true); if ($post_specific_data == -1) { return 0; // Disable } else if (!$post_specific_data) { return $orig_data; // Default } else { return $post_specific_data; // Override } }to
protected function getOverrideID($meta, $orig_data) { global $post, $wp_query; $id = false; // Is this page being used as the post_as_page? if ($wp_query->is_posts_page) $id = (isset($wp_query->query_vars['page_id']) && $wp_query->query_vars['page_id']) ? $wp_query->query_vars['page_id'] : $wp_query->queried_object_id; // Otherwise, if it's just a regular page/post or the home if (!$id){ $id = $post->ID; } // Still nothing, then don't bother if (!$id) return $orig_data; $post_specific_data = get_post_meta($id, $meta, true); if ($post_specific_data == -1) { return 0; // Disable } else if (!$post_specific_data) { return $orig_data; // Default } else { return $post_specific_data; // Override } }
The topic ‘[Plugin: Background Manager] Override getOverrideID’ is closed to new replies.