jueves, 7 de julio de 2016

How to fix deTube theme to make it work with Wordpress 4.5.x


If you have an outdated version of WordPress on your site because you can't update deTube theme, then I will show you how to fix it.

There are two fixes to be done, one for the section boxes on the home page and another one for the sidebar.

To fix home page boxes you have to edit the file
wordpress/wp-content/themes/detube/functions.php and add the line $args[‘title’] = ”; below the line $args['posts_per_page'] = $posts_per_page;


/**
* Output a Section Box
*
* @since deTube 1.0
*/

function dp_section_box($args = array()) {
$defaults = array(
'post_type' => 'post',
'cat' => '',
'taxonomies' => array(),
'view' => 'grid-small',
'title' => '',
'link' => '',
'post__in' => '',
'posts_per_page' => '',
'hide_if_empty' => false
);
$args = wp_parse_args($args, $defaults);
extract($args);

$posts_per_page = absint($posts_per_page);

// Set default posts number if no specified
if(empty($posts_per_page)) {
if($view == 'grid-mini')
$posts_per_page = 8;
elseif($view == 'grid-small')
$posts_per_page = 6;
elseif($view == 'grid-medium')
$posts_per_page = 4;
elseif($view == 'list-small')
$posts_per_page = 3;
elseif($view == 'list-medium')
$posts_per_page = 2;
elseif($view == 'list-large')
$posts_per_page = 1;
}

$args['posts_per_page'] = $posts_per_page;
$args['title'] = ''; // fix WP 4.5 compatibility issue

$args = dp_parse_query_args($args);
$query = new WP_Query($args);
...
...
...
Now that we have the section boxe fixed, let's fix the sidebar...

Look for the file wordpress/wp-content/themes/detube/wordpress/wp-content/themes/detube/widgets/widget-posts.php, there go around line 43, below $query_args['no_found_rows'] = true; add the line $query_args['title'] = '';


...
...
...


extract($args);

ob_start();

$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);

$query_args = $instance;
$query_args['no_found_rows'] = true;
$query_args['title'] = '';
$query_args = dp_parse_query_args($query_args);

$r = new WP_Query( apply_filters( 'dp_widget_posts_args', $query_args ) );

...
...
...

I hope this help some people, if so please let me know in the comments.
PS: I am available for freelance work ;)
Bitcoin donations 1PvQBKRayC7URnwFivrgJS2EVnFptuy9KP