Site logo

Archived topic

Filter hook for Theme builder's dynamic data

24 replies · Started by Ash on March 27, 2021

Viewing posts 16–25 of 25

Maybe you can explain a little bit more about what the objective is? Why are you trying to change the output, exactly?

My code will replace the dynamic data if $text_to_replace matches the text I specified in the code. If you need it to apply to other text as well, you'll need to add more to the function to target those other words.

Because customizability for them is not enough at all.

- The first Post meta need to be a badge and translated into Japanese.
- I like to apply number format to the second Post meta.
- I like to convert the the 5th Post meta to another unit.
- I like to show only first term on the Terms.
- I like to hide the 3rd, the 4th and the 5th when it's not available.

Have you try to access a post meta/a terms by your self?
The hook does not process the data other than the post title for some reason.
It could be a bug.

I just checked the source code of GPP.
It seems that I need to use these filter for post meta/terms but generate_dynamic_text_title, right?

Post meta
generate_dynamic_text_custom_field

Term
generate_dynamic_text_post_terms

Aha, you're correct, these are the filters:

Post title: generate_dynamic_text_title
Post date: generate_dynamic_text_post_date
Post author: generate_dynamic_text_post_author
Post terms: generate_dynamic_text_post_terms
Comments number: generate_dynamic_text_comments_number
Custom field: generate_dynamic_text_custom_field

The only data that is passed to these filters is the output and the $block variable, which carries all necessary information from the individual block.

Thank you

No problem!

Just a heads up that this has changed in rc.3. I wasn't a fan of a bunch of different filters here.

So now, there are two filters for all dynamic text:
generate_dynamic_element_text - you can use this to filter the dynamic value.
generate_dynamic_element_text_output - you can use this to filter the dynamic value including the dynamic link and/or before text.

Thank you.

No problem!

This archived topic is closed to new replies.