Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 基于ID向woocommerce商店网站添加自定义说明_Php_Css_Wordpress_Woocommerce_Shop - Fatal编程技术网

Php 基于ID向woocommerce商店网站添加自定义说明

Php 基于ID向woocommerce商店网站添加自定义说明,php,css,wordpress,woocommerce,shop,Php,Css,Wordpress,Woocommerce,Shop,我想为我的woocommerce商店添加自定义说明。我想在商店上显示一个不同的描述,并且描述(当点击产品时)将保持在商店上写的状态 我想把它分开。我看到它的唯一方式是,使用一些定制的html和php,但我不知道。CSS似乎没有帮助。由于我有各种产品,我想按产品ID将其分开,并自己为每种产品编写描述,使其看起来像: 这是我的文件oceanwp-strings.php: <?php /** * OceanWP theme strings * * @package OceanWP Word

我想为我的woocommerce商店添加自定义说明。我想在商店上显示一个不同的描述,并且描述(当点击产品时)将保持在商店上写的状态

我想把它分开。我看到它的唯一方式是,使用一些定制的html和php,但我不知道。CSS似乎没有帮助。由于我有各种产品,我想按产品ID将其分开,并自己为每种产品编写描述,使其看起来像:

这是我的文件oceanwp-strings.php:

<?php
/**
 * OceanWP theme strings
 *
 * @package OceanWP WordPress theme
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! function_exists( 'oceanwp_theme_strings' ) ) {

    /**
     * OceanWP Theme Strings
     *
     *  @author Amit Singh (apprimit@gmail.com)
     *  @since 1.8.5
     *
     * @param  string  $value  String key.
     * @param  boolean $echo   Print string.
     * @return mixed           Return string or nothing.
     */
    function oceanwp_theme_strings( $value, $echo = true ) {

        $oceanwp_strings = apply_filters(
            'oceanwp_theme_strings',
            array(

                'owp-string-header-skip-link'            => apply_filters( 'ocean_header_skip_link', __( 'Skip to content', 'oceanwp' ) ),
                'owp-string-search-text'                 => apply_filters( 'ocean_search_text', __( 'Search', 'oceanwp' ) ),
                'owp-string-mobile-search-text'          => apply_filters( 'ocean_mobile_search_text', __( 'Search', 'oceanwp' ) ),
                'owp-string-mobile-fs-search-text'       => apply_filters( 'ocean_mobile_fs_search_text', __( 'Type your search', 'oceanwp' ) ),
                'owp-string-header-replace-search-text'  => apply_filters( 'ocean_header_replace_search_text', __( 'Type then hit enter to search...', 'oceanwp' ) ),
                'owp-string-search-overlay-search-text'  => apply_filters( 'ocean_search_overlay_search_text', __( 'Type then hit enter to search', 'oceanwp' ) ),
                'owp-string-vertical-header-search-text' => apply_filters( 'ocean_vertical_header_search_text', __( 'Search...', 'oceanwp' ) ),
                'owp-string-medium-header-search-text'   => apply_filters( 'ocean_medium_header_search_text', __( 'Search...', 'oceanwp' ) ),
                'owp-string-comment-logout-text'         => apply_filters( 'ocean_comment_logout_text', __( 'Log out of this account', 'oceanwp' ) ),
                'owp-string-comment-placeholder'         => apply_filters( 'ocean_comment_placeholder', __( 'Your comment here...', 'oceanwp' ) ),
                'owp-string-comment-profile-edit'        => apply_filters( 'ocean_comment_profile_edit', __( 'Click to edit your profile', 'oceanwp' ) ),
                'owp-string-comment-post-button'         => apply_filters( 'ocean_comment_post_button', __( 'Post Comment', 'oceanwp' ) ),
                'owp-string-comment-name-req'            => apply_filters( 'ocean_comment_name_req', __( 'Name (required)', 'oceanwp' ) ),
                'owp-string-comment-email-req'           => apply_filters( 'ocean_comment_email_req', __( 'Email (required)', 'oceanwp' ) ),
                'owp-string-comment-name'                => apply_filters( 'ocean_comment_name', __( 'Name', 'oceanwp' ) ),
                'owp-string-comment-email'               => apply_filters( 'ocean_comment_email', __( 'Email', 'oceanwp' ) ),
                'owp-string-comment-website'             => apply_filters( 'ocean_comment_website', __( 'Website', 'oceanwp' ) ),
                'owp-string-search-continue-reading'     => apply_filters( 'ocean_search_continue_reading', __( 'Continue Reading', 'oceanwp' ) ),
                'owp-string-post-continue-reading'       => apply_filters( 'ocean_post_continue_reading', __( 'Continue Reading', 'oceanwp' ) ),
                'owp-string-single-related-posts'        => apply_filters( 'ocean_single_related_posts', __( 'You Might Also Like', 'oceanwp' ) ),
                'owp-string-single-next-post'            => apply_filters( 'ocean_single_next_post', __( 'Next Post', 'oceanwp' ) ),
                'owp-string-single-prev-post'            => apply_filters( 'ocean_single_prev_post', __( 'Previous Post', 'oceanwp' ) ),
                'owp-string-single-screen-reader-rm'     => apply_filters( 'ocean_single_screen_reader_rm', __( 'Read more articles', 'oceanwp' ) ),

                // Woocommerce.
                'owp-string-woo-quick-view-text'         => apply_filters( 'ocean_woo_quick_view_text', __( 'Quick View', 'oceanwp' ) ),
                'owp-string-woo-quick-view-close'        => apply_filters( 'ocean_woo_quick_view_close', __( 'Close quick preview', 'oceanwp' ) ),
                'owp-string-woo-floating-bar-select-btn' => apply_filters( 'ocean_woo_floating_bar_select_btn', __( 'Select Options', 'oceanwp' ) ),
                'owp-string-woo-floating-bar-selected'   => apply_filters( 'ocean_woo_floating_bar_selected', __( 'Selected:', 'oceanwp' ) ),
                'owp-string-woo-floating-bar-out-stock'  => apply_filters( 'ocean_woo_floating_bar_out_stock', __( 'Out of stock', 'oceanwp' ) ),
            )
        );

        if ( is_rtl() ) {
            // do your stuff.
        }

        $owp_string = isset( $oceanwp_strings[ $value ] ) ? $oceanwp_strings[ $value ] : '';

        /**
         * Print or return strings
         */
        if ( $echo ) {
            echo $owp_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        } else {
            return $owp_string;
        }
    }
}

您所谓的描述实际上是
的_摘录()。这几乎是你文章内容的一个简短版本。你可以在这里和这里了解更多

现在,混淆已经消除,因为每个主题团队都是不同的,您可能在主题文件的某个地方有一个用于产品的模板部分。我需要文件的代码来进一步说明

用产品模板零件代码编辑您的帖子,我会看一看


编辑1.2:在执行任何操作之前,请将产品模板的副本保存在安全的地方

if ( ! $length ) {
   echo wp_kses_post( strip_shortcodes( $post->post_excerpt ) );
} else {
   echo wp_trim_words( strip_shortcodes( $post->post_excerpt ), $length );
}
这用于从数据库中获取摘录
$post->post\u摘录
。没有与之关联的格式化

在传递格式化时,我们将使用
获取_摘录()

来源@


你真的想要不同的描述吗?听起来你已经输入了正确的描述,只是在商店页面上以不合适的格式输出。因此,负责后者的模板部分,可能应该相应地进行修改。实际上,我不想要另一个模板。我只想正确地显示它。我已经上传了我的主题使用的模板(或者我认为是模板)。谢谢你用更好的方式描述我的问题。你是对的。这是摘录。我已经更新了。我希望我选对了。非常感谢。关于您最后的评论,请参阅编辑1.1。如果这回答了你的问题,别忘了投赞成票并接受答案。我按照描述进行了编辑,但似乎不起作用。没有变化。我甚至清除了缓存,并使用另一个浏览器查看。你是自己写摘录的吗?还是自动的?我自己在WooCommerce/products下的产品选项中写的。可能所有的信息都写在“简短描述”上?我试着做一个测试,在描述应该出现的文本区域写一些东西(我改为短文本,在产品站点的图片旁边显示),但在商店页面上的描述没有改变。
if ( ! $length ) {
   echo strip_shortcodes( 'EDIT 1.2:'.get_the_excerpt() );
} else {
   echo wp_trim_words( strip_shortcodes( 'EDIT 1.2:'.get_the_excerpt()  ), $length );
}