Search Results and dynamic content

As i wrote in another post about dynamic content Dc:term:name post= not working
i’m trying to use a extra plugin for searching content.

I found Relevanssi would fit my needs https://wordpress.org/plugins/relevanssi/
But it seems that the pro shortcodes with the {{}} seems not to be indexed. I’ve had a conversation with the plugin developer and he says that the index will be processed with the “the_content()” function.

I’ve played around with this function and the correct page output was only created if use a WP_Query with “the_content()” inside a loop. While a normal get_post() and output the filtered content seems not work.

Is there a reason why the correct output is only done by a WP_Query?

Hi @Regnalf,

Thanks for reaching out.
The Dynamic Content tags are not being parsed like the shortcode and added to the Content of the WordPress. You are using the 3rd Party plugin that might use the Content only to search.

The the_content function only works with WP_Query object where get_post function returns the POST object where you need to use the post_content porperty like $post->post_content. If you need that to be filtered with the the_content, you can use the following code.

$output =  apply_filters( 'the_content', $post->post_content );

Hope it helps.
Thanks

If tried it with the following shortcode:

add_shortcode('test-content-get-post', 'test_post_content');
function test_post_content ()
{
$post_test = get_post(896);
return apply_filters( 'the_content', $post_test->post_content );
}

But no content was output!

Strange thing is, that even if i make a direct database query

$query = $wpdb->get_row ("SELECT * FROM wpbh_posts WHERE ID = 896");

the content column shows a 911 string but no content!!

object(stdClass)#24181 (23) { 
["ID"]=> string(3) "896"
["post_author"]=> string(1) "1"
["post_date"]=> string(19) "2021-05-27 11:15:33"
["post_date_gmt"]=> string(19) "2021-05-27 09:15:33"
["post_content"]=> string(911) "                                            " 
["post_title"]=> string(12) "Preise & Abo" [...

Hi @Regnalf,

I have checked your code in my local environment and it works with the available post ids. There might be a different reason behind your issue, as this is not a Theme related issue it is beyond the scope of Theme Support to investigate it.

I would suggest you hire a developer who can assist you to do the customization or you can avail of our newly launched service called One, where we answer the questions beyond normal theme support.

Thanks

Ok, i think i figured it out what that empty string is. It’s because of the longtext which is not working with var_dump. The post_content column is there as it should be.

But the apply_filters( ‘the_content’, $post->post_content ) doesn’t parse the full output. I’ll get only a small part of it:

Full RAW from Database:

[cs_content][cs_element_section _id="1" ][cs_element_layout_row _id="2" ][cs_element_layout_column _id="3" ][cs_element_text _id="4" ][cs_content_seo]Preise
{{dc:term:name term="6"}}, {{dc:term:name term="5"}}:
1. Rang € 18,-
2. Rang € 15,-
Kinder unter 15 Jahren € 8,-

{{dc:term:name term="7"}}
Kinder € 8,-
Erwachsene € 13,-\n\n[/cs_content_seo][/cs_element_layout_column][cs_element_layout_column _id="5" ][cs_element_text _id="6" ][cs_content_seo]Theaterabo
Ihre Geschenkidee -
Schenken Sie ein Theaterabo der Bühne Heidenreichstein um € 42,--.
Das Abo beinhaltet:
1 Karte {{dc:term:name term="5"}} (1. Rang)
1 Karte {{dc:term:name term="6"}} (1. Rang)
1 Karte {{dc:term:name term="7"}} (Erwachsener)
Sie sparen 14%.
Sie erhalten das Abo bei BP Tankstelle Wurz oder unter 0664/94 64 751.\n\n[/cs_content_seo][/cs_element_layout_column][/cs_element_layout_row][/cs_element_section][/cs_content]

aplly filters Output

<div id="cs-content" class="cs-content"></div>

Hi @Regnalf,

Regretfully, what you are expecting is required custom development and beyond the scope of our theme support and we can’t help on this further.

Our development team is already aware that some of the builder content is not visible to SEO and Search Plugins and they are looking for a better way to output the content in the WordPress content area.

Thanks

Ok, thx for the info.

Hi @Regnalf,

You are most welcome.

Ok, i think i found a bug in the parser, if i want to set the url in an <a> tag.

If i create a link like
<a href="{{dc:term:url term="5"}}">{{dc:term:name term="5"}}</a>
it converts it after saving to
<a href="{{dc:term:url term=">{{dc:term:name term="5"}}</a>
It cuts off the term after the "

It happens when i use the editor on the site directly, not the floating editor when pressing the text edit button.

Hi @Regnalf,

I have checked it in my local environment but didn’t find the issue you described here. The Term id still shows after the saving.

Thanks

In this editor it works, i mean the other editor directly in the builder window.

Hi @Regnalf,

I have forgotten to mention that it works in the Default Editor too. Please find the screenshot below.

Even that works fine in the Default editor, the Dynamic Content tag will not work outside the Content Builder as discussed earlier.
Thanks

No, i even don’t mean that editor, sorry i forgot to post the reproduce steps.

If i create this in the html editor in with floating editor i can create the correct output:


Bildschirmfoto 2021-08-12 um 13.54.07

If double click on edit this text section direct in the layout builder it parse the " wrong

Bildschirmfoto 2021-08-12 um 13.49.22

After this the html code looks like this.

And i can reproduce this every time.

Edit: Sorry, i don’t know when the uploaded images were scaled down.

Hi @Regnalf,

It seems that you are adding the code into the Rich Text Editor which parses the HTML Entities, which converted the < into &lt and > into &gt; and that is why the code does not work as expected. I would suggest you use the HTML editor while adding the HTML code.

Thanks

  1. If you would realy read my post, then you would see that i have a working code from the hmtl editor. (See the screenshots! I’m not a noob, i know what the html and rich text editor is!!))

  2. The html mixup happens as soon as you click on the layout builder on the right side. Or if you switch between html and rtf editor, even without changes oder clipboard paste. This should not happen in any case!

So please follow my reproduce steps or handover this case to another supporter!

Hi @Regnalf,

Sorry for the confussion, the 3rd image in your post makes me think of the Rich Text Editor. I have tried again to reproduce the problem you are facing by following the steps you explained but unfortunately, it has not been replicated.

I have already reported to other staff to check and try to replicate the issue if possible.

Thanks

Update, i’ve tried it with WP Safe Mode and deactivated all Plugins, the issue still exists!

I’ve added credentials again, see secure note.

Hey @Regnalf,

No credentials needed.

It’s because you’re using double quotes in both the HTML href attribute and in the Dynamic Content. That’s not allowed.

Try turning the double quotes of the Dynamic Content or the HTML into single quotes like the following variations.

<a href='{{dc:term:url term="5"}}'>{{dc:term:name term="5"}}</a>
<a href="{{dc:term:url term='5'}}">{{dc:term:name term="5"}}</a>

You can also omit the double quotes in the Dynamic Content if the value is a number. I don’t recommend this though because you might forget this bit and you’re working with a string value.

image

Hope that helps.

Thanks @christian, I already thought that it will probably be because of the double quotation marks.
I just wasn’t sure if it was the WordPress parser or a function of yours. Also I didn’t know that a single quote is allowed.

But thanks for the clarification, now it works as it should be. I don’t know if it’s in the documentation, but it would be worth a hint to avoid such errors with <a> url.

You’re welcome, @Regnalf. I’ll forward this case to our docs writer.