Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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 如何在WordPress中创建链接到特定文件的函数_Php_Wordpress_Function - Fatal编程技术网

Php 如何在WordPress中创建链接到特定文件的函数

Php 如何在WordPress中创建链接到特定文件的函数,php,wordpress,function,Php,Wordpress,Function,好的,我正在处理一个主题,我希望根据用户选择的设计有不同的样式和php文件。我该怎么做?我能给出的最好的例子是有一个get_template_part函数,它根据用户选择的设计更改目录。以下是我对代码外观的看法 <?php /*custom_function*/(/*Global Path variable which changes*/, '/filename') ?> x主题有类似的堆栈,我认为这可能是一个类似的想法。谢谢。函数中可能有类似的内容。php:只是一个示例

好的,我正在处理一个主题,我希望根据用户选择的设计有不同的样式和php文件。我该怎么做?我能给出的最好的例子是有一个get_template_part函数,它根据用户选择的设计更改目录。以下是我对代码外观的看法

<?php /*custom_function*/(/*Global Path variable which changes*/, '/filename') ?>

x主题有类似的堆栈,我认为这可能是一个类似的想法。谢谢。

函数中可能有类似的内容。php:只是一个示例

     <?php
       define("DESIGN", "flat");
        if(DESIGN == "flat"){
         add_action( 'wp_enqueue_scripts', 'asd_scripts' );
       }elseif(DESIGN == "notflat"){
          // other  add_action( 'wp_enqueue_scripts', '...' );
        }
       function asd_scripts() {
       // load bootstrap js
       wp_enqueue_script('asd-bootstrapjs',   get_template_directory_uri().'/includes/resources/bootstrap/js/bootstrap.js', array('jquery') );
       }
     ?>
您需要使用来实现这一点。例如,您可以使用钩子:

此挂钩允许您访问$wp_自定义对象


WordPress文档中存在一些文件,这应该让您开始做您想做的事情。

我想您不明白我的意思,我指的是根据所选设计的选择调用特定文件目录的函数。例如,如果我选择设计为平面ui,它将转到Framework/js或css,php/flat.js,但是如果我选择设计为metro ui,它将转到Framework/js或css,php/metro.js。这能让事情更清楚吗?如果我做了$Path='/Framework/Js/Flatui';然后做了一个我不知道如何编码的函数,然后做了函数$Pathcss';我最好的例子是查看主题xOk,但如何获得指定的文件?我在想一些东西,比如:mytheme_customize_register GLOBALVAR_PATH,‘flatui’;?这不会保存实际主题文件、模板文件或样式表中的任何更改。呈现网站时,WordPress将主题定制器生成的内联CSS输出到,这将覆盖样式表。你可以找到这个ik的完整教程,但我只想得到一个功能,可以让用户快速更改我的主题的代码,以使其多样化,它不必通过自定义程序进行更改,可能是通过主题设置页面?我明白,我可以建议你也许可以尝试一些你提供的选项,有很多代码示例等。不幸的是,我们无法为您编写这些函数,因为我们没有直接处理您的主题。然而,当你尝试了一些选择并陷入困境时,我们将在这里提供帮助:-好的,但我真的陷入困境,我已经做了我能做的一切,而不需要这个
function mytheme_customize_register( $wp_customize )
{
   //All your sections, settings, and controls will be added here
}
add_action( 'customize_register', 'mytheme_customize_register' );