月薪1800块的站长
不打算了解一下吗

MODOWN作为主题需要二开的地方

1、在主题fuction中添加菜单自动下拉子菜单功能

在/wp-content/themes/modown/functions-custom.php中添加一下代码

/* 自动给导航菜单中的分类添加其下的子分类 */
add_filter("wp_get_nav_menu_items", function($items, $menu, $args) {
    if (is_admin()) {
        return $items;
    }
    foreach ($items as $index => $i) {
        if ("category" !== $i->object) {
            continue;
        }
        $term_children = get_term_children($i->object_id, "category");
        foreach ($term_children as $index2 => $child_id) {
            $child               = get_term($child_id);
            $url                 = get_term_link($child);
            $e                   = new stdClass();
            $e->title            = $child->name;
            $e->url              = $url;
            $e->menu_order       = 500 * ($index + 1) + $index2;
            $e->post_type        = "nav_menu_item";
            $e->post_status      = "published";
            $e->post_parent      = $i->ID;
            $e->menu_item_parent = $i->ID;
            $e->type             = "custom";
            $e->object           = "custom";
            $e->ID               = 0;
            $e->db_id            = 0;
            $e->object_id        = 0;
            $e->classes          = array();
            $e->description      = "";
            $items[]             = $e;
        }
    }
    return $items;
}, 10, 3);

 

2、文章页单栏css需要改成全屏

到/wp-content/themes/modown/static/css/base.css 49行

.single .main .container,.page-template-default .main .container,.page-template-tougao .main .container,.page-template-ask .main .container{max-width:1200px}

修改成

.single .main .container,.page-template-default .main .container,.page-template-tougao .main .container,.page-template-ask .main .container{max-width:none}

 

3、特色图缩略图尺寸改成可以按照栏目不同而不同,原来是按照默认尺寸285X180

在后台-主题设置-样式中,设置通用缩略图高为400
在分类中选择需要特殊设置的分类的缩略图高为180
在/wp-content/themes/modown/inc/base.php中第425行
$src = "$dir/timthumb.php?src=$src&w=$width&h=$height&zc=1&q=95&a=".(_MBT('timthumb_type')?_MBT('timthumb_type'):'c');
修改为
$src = "$dir/timthumb.php?src=$src&w=$400&h=255&zc=1&q=95&a=".(_MBT('timthumb_type')?_MBT('timthumb_type'):'c');


或者在上一行添加
$height = 180*$width/285;

或者在368行修改成
if ($thumb) {
$category = MBThemes_youngest_category();
if ($category) {
$cat_ID = $category->term_id;
$timthumb_height_cat = get_term_meta($cat_ID, 'timthumb_height', true);
if ($timthumb_height_cat) {
if ($timthumb_height_cat == 180) {
$height = 180 * $width / 285;
} else {
$height = $timthumb_height_cat;
}
}
}
}

 

赞(0)
分享到: 更多 (0)