I’ve added some comments to clarify a problem with your code:
function swvideo( $html) {
if ( $html ) { // if $html == true
return $html;
}
$post = get_post( $post ); // irrelevant
if ( ! $html ) { // if $html != true
return $html;
}
...
As you can see, nothing past this point will be executed, because the input $html must either be equivalent to true, or not equivalent to true.
I can’t tell clearly what you’re trying to accomplish, but maybe advanced custom fields would help?
Related Posts:
- WordPress Gutenberg Embed Blocks Are Not Responsive
- How to register a embed handler as a fallback to a oEmbed handler?
- WordPress block editor embeds not working in theme (single.php)
- Video Block does not autoplay
- How can I block embeds and show an individual preview image per block?
- How can I display instagram block with parse_block?
- Block editor: Sandbox iframe shows outdated HTML
- Lazy load video block while keeping autoplay
- Not allowing my site to be embedded elsewhere via oEmbed
- Override base Gutenberg block default spacing in child theme’s theme.json
- Embeds (YouTube, Spotify) Work Live but Won’t Load in Block Editor [closed]
- Remove block styles in the Block Editor
- Are there ways to make the Gutenberg editor wider? And the HTML-block higher?
- Blocks: set a default value for a TextControl
- Is there a list / reference for all current native WordPress blocks?
- Extending Gutenberg group block: How to properly combine multiple attributes?
- Required (mandatory) Gutenberg block
- Add classname to Gutenberg block wrapper in the editor?
- Help with using getBlockIndex
- Best practices for CPT without using an editor [closed]
- Gutenberg – Custom blocks onClick not working?
- Get blocks from other pages, from within current page
- Your site doesn’t include support for the block… after registering a block
- .editor-styles-wrapper overriding my block styles in Gutenberg
- Remove a component fill from a Block Editor panel
- Add a button to the toolbar of an existing Gutenberg block
- JSON File in Gutenberg
- Show date post published in Gutenberg component
- Adding an html wrapper to a custom Block Pattern
- How to add a class to the element in a custom Gutenberg block
- Video Embed with Captions in Turkish
- Gutenberg: How to check if a block is used in a paginated post?
- Editor API Endpoint or Data Store That Provides a List of Meta Fields for Post Types
- Specify exact parent child relationship between two blocks
- Using custom Entities to retrieve external data in the Block Editor
- How can I remove a button from the paragraph block toolbar?
- Align Group blocks left or right
- Unable to override MediaPlaceholder component
- Run the edit function of parent block when something changes in InnerBlocks
- do_blocks does not include its CSS
- Track Block Pattern Insertion Within the Block Editor
- block variations registration in PHP
- How to add screen reader text to links inserted in the block editor?
- Auto synchronize saving of custom block editor entities
- Store data from nested block of gutenberg
- Output content of post excerpt into Innerblocks within Gutenberg block
- How to add a link in a translation in gutenberg
- component does not render in block save
- Adding block programmatically to InnerBlocks
- How to use Gutenberg blocks in widgets?
- Don’t expand “Most Used” accordion item when adding new block
- React useEffect not work in frontend gutenberg blocks
- Gutenberg Block language translation does not work
- How to generate block ID for use in post_content JSON data
- Where in a WordPress installation is the code for the default Gutenberg blocks located? [duplicate]
- ACF and Gutenberg block, how to use blocks without ?
- Submitting a block to the .org repo: do I submit compiled code, or source code? [closed]
- Using 2 HTML blocks in Gutenberg to wrap content with div
- Add button to Block toolbar: toggleFormat is undefined
- What is the name of the user capability to read a reusable block?
- Gutenberg – Prevent Column Nesting in the Visual Editor
- How to remove whitespaces from source of posts created through WordPress Gutenberg editor
- Gutenburg: Remove border of selected block
- Sort Posts by Sticky then by Latest date using the Latest Posts Block
- Unwanted white space next to inputs added within `PluginDocumentSettingPanel` using “
- apiFetch() returns infinite requests
- ToolbarDropdownMenu component missing from @wordpress/scripts package
- Gutenberg Custom Block Not Validating – Ideas?
- Gutenberg dynamic block render_callback gives null for $post
- Editing HTML structure of Gutenberg layout recent post?
- How to add srcdoc attribute to YouTube oEmbed in Gutenberg oEmbed Block
- Pass props / function to InnerBlocks
- Embedded videos not displaying on page
- Categories in Gutenberg
- Why does Gutenberg adds 4 around blocks? And how to change this?
- Have parent block’s isSelected be true if an innerblock is selected?
- How can I add the option to format to list in RichTextToolbarButton?
- Layout Settings in the new Gutenberg editor
- How to get blocks with same heigh in columns?
- Gutenberg: Issue trying to commit locally
- Get postId in a wordpress pattern file?
- Remove placeholder from core/image in InnerBlocks template
- Gutenberg block not displaying prop values
- ACF InnerBlocks breaks css grid, How can we add classes to allowedblocks (WordPress Gutenberg)
- Adding custom link text to a URLInputButton
- Rearrange order of block into a block category gutenberg
- Gutenberg Block Deprecation – Handling old viewScript and styles
- Resaving posts to update static blocks
- How to dynamically add style tags to Gutenberg editor in react
- When to use the second parameter to useSelect?
- How to set autoload from “yes” to “no” _transient_wp_core_block_css_files
- Consistent inline styling in a Gutenberg-paragraph-block
- Add additional scripts and markup in the section of default Gutenberg theme
- How can I lock innerblocks but not it’s content?
- Youtube embedded videos unavailable
- Responsive rules with block themes and theme.json
- WordPress 6.4 – How to select a different menu I have created?
- Prevent block variation inside certain parent blocks
- how can I properly extend the gutenberg terms block?
- How to set background color of template part in Site Editor?