Trying to store markup in the database is generally a bad idea– some reasons being:
- Certain characters need to be escaped to be put in the database
- Having markup in the database will negatively effect any searches
you may need to run on the data, now or in the future. - Having markup in the database will complicate attempts to reuse the
data in different contexts, now or in the future.
Just store the raw data in the database and format it on output. The basic code would look like:
$meta = get_post_meta($post->ID, 'post_subtitle', true);
if (!empty($meta)) {
$mstr="<span class="some-class"".$meta.'</span>';
}
You can automate that by creating a shortcode or by inserting it using the the_content
filter, for example.
Related Posts:
- How to customize the default HTML for WordPress Attachments
- Selecting An image from the Media LIbrary on the frontend
- What is the most idiomatic way to let clients edit phrases in HTML?
- Publishing html directly from ftp to wordpress
- How do I change the markup only of a built-in widget?
- Is it possible to add a ribbon in the background of h1 on every page?
- Edit sticky header html – How to locate corresponding php file
- How can I have a common background color across multiple WordPress blocks?
- “woocommerce_form_field()” function having issues after latest woocommerce update [closed]
- How do I hide an article element so only logged out users see it
- Upload a web module (html and JS) to wordpress
- Custom CSS Nav Menu Style Not Being Applied
- Easily add custom HTML outside the main container?
- Add producthunt badge to wordpress menu
- how to add custom html and css to wordpress
- Move text from the side of image to below image [closed]
- WooCommerce – Adding custom HTML to specific product pages
- Adding Custom HTML/CSS/JS code in specific page
- Making custom pages (with an example to explain the goal)
- How to create a shortcode with HTML code in it and custom parameters/
- how can i change the html and the css of my word press theme that I bought?
- adding new html css to wordpress section from codepen [closed]
- How to *remove* a parent theme page template from a child theme?
- How to disable page delete
- WordPress hook before inserting post into database
- How to update the delete user confirmation form?
- Enable / Add Custom Keyboard Shortcuts To Work With WordPress’ HTML Editor
- In the new Theme Customizer API, how to send a value from the front back to the admin panel?
- How do I add Post Like and Bookmark Functionality to my WordPress Site?
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Print shortcode in custom action hook not where the shortcode is entered
- simple expandable vertical menu, java script problem
- What is causing this error? “Warning: Invalid argument”
- sanitize attachment filename
- Modifying loop on a custom page, strange behaviour
- WordPress native “playlist” shortcode. Next and Prev there are but with no icons. How to fix?
- Best way to integrate an existing PHP application into WordPress
- Add filename to attachment page url
- Show post page only if the user has bought a specific product
- How do I add a new template to my site
- Create simple Cookie Box for WordPress
- Does wordpress prevent non wordpress pages from being allowed on the same domain?
- Different development environments (Mac & Windows)
- How to add custom page attributes in WordPress?
- How can I use a Tiny MCE editor in my custom Gutenberg block?
- Is there a way to set the value and text for Select/Radio/Checkbox using More Fields?
- the_post_thumbnail() returns nothing even though has_post_thumbnail() returns true
- orderby in query_posts
- How to customize and keep things up-to-date?
- Problem with custom user meta field
- What are “best practices” for wp-config.php
- Instant install of wordpress
- What happens to the mu-plugins folder when you upgrade to WordPress 3?
- digital alarm clock widget
- In WordPress 3.x, I can’t access posts from all blogs in the network
- WordPress Install Issue, Receive Warnings But Successful Install
- how to make a custom field readonly or disabled by user role?
- How to make wordpress use a non-wordpress users table?
- Allow multisite admins only to create users with one specific user role?
- Make tag archive display post are ordered by post format
- How to move meta information in TwentyTwelve’s single post template?
- How to Clear Empty Search values?
- saving the widgets position after drag and drop
- Google calendar in wordpress showing events
- Custom menu not showing even though it shows as being registered?
- Open login logo URL in new tab
- Create Miltiple Category Base
- Delete a column in edit.php generated with a plugin
- Get /users/me details from WordPress backend
- Migrating my site to a new domain does not keep any changes made in customizer
- How to show the hero of website when sending website link?
- How to get WordPress Theme Customizer options in the REST API?
- How to use the same custom page template to iframe multiple urls with entry of new url entered from backend
- Creating a WP Test site without /uploads etc
- Where to put coding a validation script for store? [duplicate]
- How to define active widget with js in a customizer
- where can i find the login page in wordpress and add my header to it
- Unable to write error_log output… but only from a certain function
- Best way to sort posts with different types by distance
- ‘str_replace’ and ‘strtr’ not working inside plugin
- SAving PHP in custom wordpress option field
- Does WordPress support template resources/custom fields
- Change default “Apply Changes To” radio option when editing images
- Edit a custom admin page
- If I delete my wordpress site then does that delete all my sites?
- Remove Twenty Twelve themes responsiveness in Internet Explorer
- Looking for a way to take readers to random post when clicking a link
- Cannot upload to S3 using CDN Sync Tool
- Custom Import with taxonomies
- Customise default site setup
- Adding a third custom taxonomies
- HTML in PHP problem [closed]
- Very Simple Geo targeting
- Consolidate ‘add-to-cart’ buttons into one ‘add-all-to-cart’ button
- Update to WordPress 4.9.2, but have heavily customized theme
- Storing form data into wordpress database [closed]
- Background image no more visible in the preview
- I need to make the title of the page dynamic in my custom plugin
- Custom CSS working on home page but not on NEW created PAGE
- Custom Menu (only showing direct cildren) ACF not showing