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

[FEATURE] Create helper that can load reusable block in the template without the need to write large iterations of the code #459

Open
iruzevic opened this issue Oct 14, 2021 · 2 comments
Assignees
Labels
improvement Small improvement fixes, either readability or performance improvements

Comments

@iruzevic
Copy link
Member

This is the code example:

$commonContent = \get_field(ThemeOptions::FIELD_ARTICLE_COMMON_BLOCKS_KEY, 'option');

	// Load custom page set in theme options for listing intro.
	if ($commonContent) {
		$blocks = parse_blocks(get_the_content(null, null, $commonContent));

		foreach ($blocks as $block) {
			echo \apply_filters('the_content', \render_block($block)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}
	}
@iruzevic iruzevic self-assigned this Oct 14, 2021
@iruzevic iruzevic added this to the 5.1.0 milestone Mar 18, 2022
@iruzevic iruzevic added the improvement Small improvement fixes, either readability or performance improvements label Mar 18, 2022
@iruzevic iruzevic modified the milestones: 5.1.0, 5.2.0 Mar 18, 2022
@iruzevic iruzevic removed this from the 5.2.0 milestone Apr 14, 2022
@DjidjaleskaSandra
Copy link

DjidjaleskaSandra commented May 13, 2024

In the theme options, it is necessary to have a dropdown list with templates, and accordingly, to select a template and which reusable block would be used in it? Or you have a different idea of how the templates and helper function could be connected?

@iruzevic
Copy link
Member Author

helper is a helper no mater where the data is coming from it should be agnostic and you should pass the content via function arg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Small improvement fixes, either readability or performance improvements
Projects
None yet
Development

No branches or pull requests

2 participants