Woocommerce - Автор био на странице продукта - PullRequest
0 голосов
/ 06 июня 2018

Я создаю собственную тему для отдельной страницы продукта для категории книг.Я использую тему themerex bookshleft для wordpress и дополнительные теги плагина (themerex тоже), которые добавляют авторские теги для каждой книги.Но я хотел бы показать биографию автора на странице отдельной книги, а не только ссылку автора, которая появляется в сводной информации о продукте woocommerce между метаинформацией.Я попытался вставить этот хук в файл content-single-product-books.php, но он не работает:

<div class="col2-responsive" style="float:left;">
    <h3>O autor</h3>
    <?php   
    add_action('woocommerce_author', 'themerex_book_author', 10);
    do_action('woocommerce_author', 'themerex_book_author', 10);

    ?>
</div>

Модуль дополнительных тегов создал этот хук themerex_book_author в файле дополнительных тегов в строке 53:

    //Hook into the 'init' action
    add_action('init', 'themerex_book_author', 0);

Функция для этого крючка:

if (!function_exists('themerex_book_author')) {
                function themerex_book_author()
                {

                    themerex_require_data('taxonomy', 'authors', array(
                            'post_type' => array('product'),
                            'hierarchical' => true,
                            'labels' => array(
                                'name' => _x('Authors', 'Taxonomy General Name', 'themerex'),
                                'singular_name' => _x('Author', 'Taxonomy Singular Name', 'themerex'),
                                'menu_name' => __('Author', 'themerex'),
                                'all_items' => __('All Authors', 'themerex'),
                                'parent_item' => __('Parent Author', 'themerex'),
                                'parent_item_colon' => __('Parent Author:', 'themerex'),
                                'new_item_name' => __('New Author Name', 'themerex'),
                                'add_new_item' => __('Add New Author', 'themerex'),
                                'edit_item' => __('Edit Author', 'themerex'),
                                'update_item' => __('Update Author', 'themerex'),
                                'separate_items_with_commas' => __('Separate authors with commas', 'themerex'),
                                'search_items' => __('Search authors', 'themerex'),
                                'add_or_remove_items' => __('Add or remove authors', 'themerex'),
                                'choose_from_most_used' => __('Choose from the most used authors', 'themerex'),
                            ),
                            'show_ui' => true,
                            'show_admin_column' => true,
                            'query_var' => true,
                            'rewrite' => array('slug' => 'authors')
                        )
                    );

                }
            }

, но я не знаю, как использовать его в своем пользовательском шаблоне для одной страницы книги.Я благодарю любую помощь!

1 Ответ

0 голосов
/ 08 сентября 2018
<div class="col2-responsive" style="float:left;">
<h3>O autor</h3>
  <?php   
     do_action('woocommerce_author', 'themerex_book_author', 10);
  ?>

просто используйте do action на странице отдельного продукта и запустите ваш код fuctions в add_action hook в fuctions.php или в вашем плагине.тогда этот код автоматически сработает в действии do

    add_action('woocommerce_author', 'themerex_book_author', 10);
if (!function_exists('themerex_book_author')) {
            function themerex_book_author()
            {

                themerex_require_data('taxonomy', 'authors', array(
                        'post_type' => array('product'),
                        'hierarchical' => true,
                        'labels' => array(
                            'name' => _x('Authors', 'Taxonomy General Name', 'themerex'),
                            'singular_name' => _x('Author', 'Taxonomy Singular Name', 'themerex'),
                            'menu_name' => __('Author', 'themerex'),
                            'all_items' => __('All Authors', 'themerex'),
                            'parent_item' => __('Parent Author', 'themerex'),
                            'parent_item_colon' => __('Parent Author:', 'themerex'),
                            'new_item_name' => __('New Author Name', 'themerex'),
                            'add_new_item' => __('Add New Author', 'themerex'),
                            'edit_item' => __('Edit Author', 'themerex'),
                            'update_item' => __('Update Author', 'themerex'),
                            'separate_items_with_commas' => __('Separate authors with commas', 'themerex'),
                            'search_items' => __('Search authors', 'themerex'),
                            'add_or_remove_items' => __('Add or remove authors', 'themerex'),
                            'choose_from_most_used' => __('Choose from the most used authors', 'themerex'),
                        ),
                        'show_ui' => true,
                        'show_admin_column' => true,
                        'query_var' => true,
                        'rewrite' => array('slug' => 'authors')
                    )
                );

            }
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...