If you are using Gutenberg:
- In your WordPress dashboard, click Posts or Pages.
- Select Add New or hover over an existing post or page and select Edit.
- Place your cursor where you want to display the code.
- Click the Add Block icon (the plus sign) and search for “code”. Select the code block when it appears.
If you are using the Classic Editor
Display code snippets by using the preformatted text option.
- Open the post where you want to include the code using the classic editor.
- Enter your code in a text box
- Highlight the code snippet and choose the preformatted text option from the dropdown.
Edit: Gutenberg Example:
<ul id=”mylist”>
<li id=”list-item3″>text 3</li>
<li id=”list-item4″>text 4</li>
<li id=”list-item2″>text 2</li>
<li id=”list-item1″>text 1</li>
</ul>
Screenshots showing results here:
Related Posts:
- How to view Plugin Manager in Notepad++
- I found this in a plugin. What does it do? is it dangerous?
- How to do I get a list of active plugins on my wordpress blog programmatically?
- How to Display Product specific to a category with WooCommerce Plugin? [closed]
- How to add field for new site-wide option on Network Settings screen?
- Redirection plugin – how to let the editor access the ‘redirection’ menu?
- Can I make plugins required?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- Advice on naming files for a plugin
- How to make search engine index PDF files? [closed]
- Self Develop or Plugin as first option?
- Is there any debug toolbar that shows whick hooks are called for the current page in WordPress?
- Adding a Variable Product in WooCommerce Programatically
- For performance is it better to build custom functionality into the theme or a plugin
- Output in XHTML or HTML 5 for plugins?
- WordPress tips for speed and performance [closed]
- Save and retrieve custom plugin options value
- Best WP cache plugin for large site [closed]
- How much should I charge for creating a WordPress plugin? [closed]
- Add Archive Page Template via Plugin
- How to access options of Redux framework in front end
- Using tabs for wordpress plugin
- How do I add a widget programmatically to a newly created site (WPMU) within a plugin?
- How to get user-meta from Social Login registered users?
- How can I save repeatable fields with one value inside an array?
- Duplicate settings of master blog to slave blogs in WP multi-site installation
- Tracking last login and last visit
- Rename existing old uploaded images containing accented French characters (not during upload)
- Woocommerce: change user role after completing order
- Prevent page slug from interfering with custom post type archive permalink?
- Automatic updates not working/plugins not installing
- append stylesheet via shortcode
- Send batch of posts as HTML Email?
- Translate third party plugin and save translation files in custom theme
- Trying to add admin file upload form plugin
- wp_verify_nonce() why return false?
- What’s the best plugin for allowing javascript in a post or page? [closed]
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Remove action from woocommerce barcode plugin [closed]
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- register_theme_directory somehow “fails” when folder is outside of WP-Folder
- Disable / Deregister all JS from all plugins
- Do extra plugin files get deleted during an upgrade?
- Adding a custom line of text to php code
- How to call bind function in wordpress actions or hooks
- clean wp_options table unused rows
- WordPress plugin for mail subscriptions [closed]
- Plugin allowing for artists, events and venues
- Disable Other Plugins on my Custom Post Type?
- Passing RichText attributes to function onChange
- Getting media library popup in custom plugin admin page
- Creating a plugin that will add options. Where should the options menu pages go?
- shortcodes displaying outside of content area with echo statement, not what I wanted [duplicate]
- Shortcode is not working in homepage page template (custom front page)
- wp_authenticate but not logged in
- How to write one comment and publish on every post using database or plugin?
- How to automate wordpress plugin activate and deactivate by php logic?
- Prevent WordPress plugin from connecting to its server
- How to create PDF file upload field for post like meta box field admin side?
- ‘wp_login’ action hook not working with wp-login.php file
- HTML in WooCommerce settings
- Can WordPress Plugin Directory Cache Delay the Upload of Images?
- Redirecting to home page after login as custom role WordPress
- Only allowing some email addresses to create an account
- Where (or when) should I register a new taxonomy?
- Widget with same content across several websites
- Hook (or other way) to find out when another plugin is activated / installed
- Issue using wp-load.php in WordPress Plugin Development
- How to change custom post type pemalink Hierarcy
- Get post values of form created by widget in sidebar
- WordPress plugin compatibility explaination when wordpress releases its new version (theoretical)
- Calendar Solution: Handling upcoming Dates with Posts?
- Fixing WordPress’s Bug (failed to send buffer of zlib output compression) results in “White Screen of Death”
- How to tie dark mode with prefers-color-scheme webkit? [closed]
- how to oauth1 Wp plug-in revoke/reset.?
- Disable woocommerce cookies and delete cart data automatically
- Why required field not working in Country dropdown in WooCommerce –
- WordPress: cleaning media library
- How to identify the names of deleted plugins?
- Why can’t I access my Intranet LDAPS with NADI?
- qTranslate remove default directory from link
- WordPress adding a menu page when activating a plugin
- How to Display Taxonomy Custom Meta Box Data in Archive Page?
- Cannot display settings field
- Custom User meta field display
- WordPress 4.2.1 pre_get_comments doesn’t work after update
- Create Custom Coupon Type
- Text Wrapping in WPDataTables
- how to show selected options drop down menu values in attributes field in after saving post.php
- fatal erro in one line if statment in wordpress plugin [Solved]
- YOAST slug does not take the custom permalink I have made
- How to check record is exist or not in WordPress CRUD Operation with $wpdb
- Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
- Best approach to change mobile background image and adding its class
- Including Google Map within a wordpress plugin
- WordPress broken dashboard with ninja-shell text
- wp-login 404 page not redirecting to homepage [closed]
- WordPress Paypal Error “Authentication with PayPal failed: Could not create token.”
- How to show custom post type in all post section?
- Convert WordPress into Event and membership managment software [closed]