Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying Dynamic text #58626

Open
TheRamSan opened this issue Feb 2, 2024 · 2 comments
Open

Displaying Dynamic text #58626

TheRamSan opened this issue Feb 2, 2024 · 2 comments
Labels
[Block] Paragraph Affects the Paragraph Block [Package] Rich text /packages/rich-text [Type] Enhancement A suggestion for improvement.

Comments

@TheRamSan
Copy link

What problem does this address?
Now there in no built-in method to dynamically display data within content in wordpress and that presents a challenge for users of various WordPress themes. Whether it's displaying the current year or changing statistics, users often encounter difficulties in updating dynamic content without resorting to plugins or manual template modifications. This manual intervention not only disrupts workflow efficiency but also introduces potential errors and maintenance overhead.

For example:
I’m using the Twenty Twenty-Three theme for my WordPress website and I’d like to display the current year dynamically within a paragraph, rather than hardcoding it. Ideally, I want the year to automatically update on the fly each year without requiring manual edits.

For example, the paragraph would currently say:
“We are now in 2024!”

But on January 1st, 2025 I want it to be changed automatically to:
“We are now in 2025!”

What is your proposed solution?
I propose integrating a flexible and user-friendly mechanism within WordPress themes to facilitate the dynamic display of content without the need for external plugins or manual code adjustments. By incorporating a built-in feature to handle dynamic data within content blocks or templates, users can effortlessly showcase changing information such as the current year, upcoming events, or other time-sensitive data points.

If we cannot do it codeless - so maybe add to the block template a way to add the relevant php code like you ca in the older classic themes in which you can edit the template and include some PHP to do it.

I think that this solution aligns with WordPress's commitment to user empowerment and accessibility by streamlining common tasks and reducing dependency on external resources. Providing users with intuitive tools to manage dynamic content enhances the overall user experience and encourages creativity in content creation.

I think that implementation this feature across WordPress themes, will empower users to seamlessly integrate dynamic data into their content without unnecessary complexity or reliance on third-party solutions.

Thank you for considering this enhancement request

@TheRamSan TheRamSan added the [Type] Enhancement A suggestion for improvement. label Feb 2, 2024
@jordesign jordesign added [Block] Paragraph Affects the Paragraph Block [Package] Rich text /packages/rich-text labels Feb 4, 2024
@Mamaduka
Copy link
Member

Mamaduka commented Feb 5, 2024

I believe this would be possible with the Block Bindings API.

@SantosGuillamot, can you confirm it?

@SantosGuillamot
Copy link
Contributor

Yes, I think this should be possible 🙂 A new source to handle those use cases would be needed though.

The same way we are using the block bindings API to connect block attributes and custom fields, anyone could create a source to handle this dynamic data. Then, just pointing the content of a paragraph or a heading to that source like this should work:

<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"my-plugin/dynamic-data","args":{"key":"current_year"}}}}} -->
<p>Current year</p>
<!-- /wp:paragraph -->

Bear in mind that this is just an example of how it could work.

Or we could maybe even create a "function" source that runs any PHP code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Paragraph Affects the Paragraph Block [Package] Rich text /packages/rich-text [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants