【问题标题】:Adding elements from various elements into one container but won't be contained将各种元素中的元素添加到一个容器中但不会被包含
【发布时间】:2017-07-09 03:25:51
【问题描述】:

我想重新组织我的单一课程页面(我想可以与 woocommerce 的单一产品相媲美)。我选择添加一个具有 inline-flex 布局(浅蓝色背景)的容器,并创建一个部分,在其中添加来自各种操作的内容。现在我设法将标题和内容添加到此父部分,但是当我尝试添加按钮时,它们出现在该部分之外。即使我在添加动作的过程中是一致的。任何(其他)方法可以将按钮放入该部分?提前致谢!

add_action( 'sensei_single_course_content_inside_before', 'add_attributes_to_header', 20 );



  function add_attributes_to_header(){
    add_action( 'sensei_single_course_content_inside_before', open_container_div_section() ,7); 
//Opens the second container in the header bar(the one you see highlighted in the picture)

    add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', add_the_title_to_header()), 50 ); 
    //Adds 'deel 1 - hoofdstuk 1'

    add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', the_content()), 51); 
    //adds 'met een header3' and the other text below that

    add_action( 'sensei_single_course_content_inside_before', add_the_button_to_header(), 52); 
    //calls seperate function to place the button, but fails to get it in the container

    add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', 'the_course_enrolment_actions'), 55);  
    //THIS also adds the button, but also puts it beside the container 

    add_action( 'sensei_single_course_content_inside_before', close_container_div_section() ,75); 
    //Closes the section container in the header bar
    }

【问题讨论】:

    标签: wordpress woocommerce hook-woocommerce woothemes


    【解决方案1】:

    最后设法通过包含自定义插入的 do_action() 来修复它。

    在创建的标题中我调用:

    add_action( 'sensei_single_course_content_inside_before', open_container_div_section() ,22);
    

    然后:

    do_action('add_elements_to_section');
    

    最后:

    add_action( 'sensei_single_course_content_inside_before', close_container_div_section() ,75);
    

    然后我向这个自定义钩子添加一个动作:

    add_action('add_elements_to_section', 'add_them');  
    function add_them(){
        add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', add_the_title_to_header()), 50 );
        add_action( 'voeg_elementen_toe_aan_section',array( 'Sensei_Course', 'the_course_enrolment_actions'), 21); 
    }
    

    完美运行!现在所有元素都安全地位于节容器中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 2012-02-28
      • 2015-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多