doufocheng6233 2017-03-06 12:38
浏览 161

Wordpress自定义字段与翻译一起使用

This seems like it should be easy, but I seem to have trouble getting it to work.

I have a Wordpress site using qtranslatex and I want to be able to use the language switching tabs in the Custom Fields section. Qtranslatex has a setting to enter an element 'id' or 'class'. That is fine for the 'Value' field in the 'Add New Custom Field', it has a simple 'id' that can be used. If there are custom field values already entered, there is the problem. Wordpress creates a new 'id' for each 'Value' field for each page, thereby making it impossible to list all the 'id's that get created.

I checked out the element and Wordpress currently does not add a 'class' to the Custom Field 'Value' textarea.

All I want to do is an add_action() or add_filter() in my functions.php file to modify the function located in template.php called '_list_meta_row' that generates the HMTL for the Custom Field 'Value' textarea. Just want to stick a "class='custom-field-value'" into the HTML.

Please help. Thanks.

  • 写回答

1条回答 默认 最新

  • dql1978dql1978 2017-03-08 09:46
    关注

    This was not exactly the kind of answer I was looking for, but I figured out a basic solution using jQuery. I was hoping to just do something in php.

    I created this jQuery function that adds a 'class' to each of the Custom Field Value elements.

    jQuery(document).ready(function($){
    
        $('[id^="meta-"][id$="-value"]').each(function(){
            $(this).addClass('custom-field-value');
        });
    
    });
    

    Now in the qTranslateX settings under the Integration tab there is a place to set a id or class for Custom Fields. So, I just set the class setting to 'custom-field-value' as it shows in my script above.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题