drphfy1198 2015-03-23 18:38
浏览 30
已采纳

Genesis Framework - 如何切换主钩子和侧边栏钩子顺序

I recently started using Genesis Framework and am still getting accustomed to the hooks used to create the layout.

The page I am designing uses the left sidebar as main navigation. It works great until it collapses on smaller screens; the sidebar goes to the bottom, below the main content.

I tried searching for a solution since it seems it may be something common, but no success.

The process that I think would solve it is to use remove_action to remove sidebar and main content to then bring them back with add_action in a different order. For this I need to know the exact name of the hooks and the order number (if specified).

Please let me know what you think would solve this and, if I am in the right track, how would you change the order.

  • 写回答

2条回答 默认 最新

  • doumou1864 2015-03-26 00:55
    关注

    Just in case you need, here's the answer to your question.

    This is how you remove the page content.

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    

    This is how you remove the sidebar in a page.

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    

    And this is the hooks before content and sidebar.

    genesis_before_content
    

    In your case let's use this codes in functions.php

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    add_action( 'genesis_before_content', function(){
        echo '<aside class="sidebar sidebar-primary widget-area" role="complementary" itemscope="itemscope" itemtype="http://schema.org/WPSideBar">';
        echo genesis_do_sidebar();
        echo '</aside>';
    }, 2 );
    

    Hope this can help you in the future.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建