您如何使用 search.php 获取在普通 wordpress 搜索功能中索引的短代码内容和其他 templates.php 文件内容或 ACF 内容 [英] How do you get shortcode content and other templates.php file content or ACF content indexed in the normal wordpress search feature using search.php

查看:71
本文介绍了您如何使用 search.php 获取在普通 wordpress 搜索功能中索引的短代码内容和其他 templates.php 文件内容或 ACF 内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试对这个问题进行一些研究,

I've been trying to conduct some research on this issue,

例如构建一个短代码让我们说我有这个功能

So building a shortcode for example lets say I have this function

function example_shortcode($content, $atts){

    $disclaimer = $atts['disclaimer'];

    return "<div>$disclaimer</div>";

}

add_shortcode("example_shortcode","example_shortcode");

买有

$content //variable passed to the example_shortcode();

这种对短代码有效,只要它是标准输出的

This sort of works for shortcodes as long as it is output by the standard

the_content(); //function through the wordpress wysiwyg

但是假设我将该函数调用到 custom-template.php 文件中,并将该模板添加到 WordPress 的页面编辑器属性中,而不是使用所见即所得,那么在前端进行搜索时,短代码内容不会出现网站.对我来说,我觉得 wordpress 应该在未来更智能地处理这个问题,尤其是因为使用通过 wordpress 加载的自定义模板.但例如

But lets say I call the function into a custom-template.php file and add that template to the page editor attributes for WordPress instead of using the WYSIWYG, then the shortcode content wont appear when doing a search on the front end of the site. To me I feel like wordpress should process this this more intelligently in the future especially since using custom templates loaded through wordpress.But for example

i.e. example.com/?s=test

这里我接下来需要开始理解什么概念,我知道是不是通过the_content()处理了shortcode;功能它会像前面提到的那样工作,

What concept do I need to start understanding next here, I know if the shortcode is processed through the_content(); function it will sort of work as mentioned earlier,

但实际上我的问题的第二部分是使用输出到 custom_functions() 的高级自定义字段来处理 custom-template.php 文件;然后被调用到 custom-templates.php 中,然后通过 wordpress 页面编辑器的页面属性加载,我的内容和一切正常都没有显示在 wordpress 前端网站本身的搜索结果中?

But really the second part of my question, is just dealing with custom-template.php files using Advanced Custom Fields being output into custom_functions(); then being called into custom-templates.php which are then being loaded through the page attributes of the wordpress page editor, my content and everything works just doesnt show up in search results on wordpress frontend site itself?

我在互联网上搜索了很多次这个问题,似乎没有多少人关心这个问题,因为我找不到太多的研究或研究很难找到,或者我搜索错误.

I've searched the internet for this issue many times, doesn't seem like many people care about this issue, as I can't find much research or the research is tough to find, or I'm searching incorrectly.

谁能开始为我指明正确的方向,以及有关该主题研究的新提示.

Can anyone start pointing me in the right direction, and new tips on research for this topic.

感谢大家的任何意见和建议.

Thank you all for any comments and advice.

推荐答案

我与 Relevanssi Better Search for Wordpress 的插件作者一起进行了无数小时的研究.

Ive conducted countless hours of research, along with the Plugin Author of Relevanssi Better Search for Wordpress.

所以我想在这里分享解决方案.

So I wanted to share the solutions here.

https://wordpress.org/support/topic/search-not-included-php-hard-coded-content/#post-14432554

这个堆栈溢出问题也与这个问题有关 这里

This Stack Overflow question is also related to this question here

这篇关于您如何使用 search.php 获取在普通 wordpress 搜索功能中索引的短代码内容和其他 templates.php 文件内容或 ACF 内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆