i’ve already solved it, i had to change the $title = get_the_title();
to $title = get_post()->post_title;
in the end it looks like that:
<?php
$title = get_post()->post_title; // Get the title string
$parts = explode(' - ', str_replace('–', '-', $title)); // Replace em dash with en dash and split the title
$artist = trim($parts[0]); // Get the artist and trim any extra spaces
$song = trim($parts[1]); // Get the song title and trim any extra spaces
?>
Related Posts:
- woocommerce related product title length
- Insert content into head tag with function
- how to replace h1 entry title with h2 in category pages only
- Site title not showing. Please help me
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- Mega Menu Walker
- Displaying Logged-In User Name in WordPress Menu
- Autoloading in Child Theme
- How to add a class to the attachment images
- Set media upload attachment link to none and hide it in WP v3.5
- Execute a shortcode when clicking on a image
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- How to add default images into theme customizer image control?
- Successful or Error Message after running mysql code in functions.php
- How can one utilize a variable as a callback function name for add_settings_field
- Change logo based on incoming domain
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- Count the number of times the search form template gets included on a page
- PHP code inside shortcodes
- How do I display a user’s previous orders as a select box option on a product?
- Adding Default Settings to Theme My Login plugin
- Remove meta description on certain pages
- Image media upload metabox
- How to combine wordpress_logged_in cookies in one cookie?
- function to assign user role based on a field from usermeta
- Woocommerce related product text
- esc_html_e() is not translating string in wordpress [closed]
- WordPress Gravatar filter is removing my custom attributes
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Limit 1 global comment per minute
- Remove echo from shortcode
- Is there a way to conditionally check whether a WordPress post title is empty?
- Copyright info change – Corporate Plus Theme PHP [closed]
- Inject class in body when particular page template is used
- Echo a function inside a function
- Use WordPress function in php file
- How to list posts from a plugin taxonomy?
- wp_force_remove_style’ not found
- Pagination on Custom Post
- first instantiated SimplePie object cosumes 5mb?
- Theme not calling Jquery properly
- WordPress redirect redirecting too many times or not at all
- how to save checkbox data for custom setting?
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- change title page on search result
- Enqueing External JS on the remote server JS
- iframe not showing in content on blog page
- Open and closed function [closed]
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Remove submenu item from list
- Customize field names in backend profile edit page through function.php [duplicate]
- How do I choose not to display the title header on a specific page?
- Remove role of user after X days
- User filter posts by year
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- Getting text from custom field from customizer
- Time Delay a URL Redirect for Specific Page
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Adding wp users ID into a link address from a DIVI modul
- Execute function only for specific user roles
- Limit Search to Product Pages only unless I’m on Blogpage or Blogposts
- WP query posts BUT show the most recent and one per author
- Block error message in foreach loop when looping through ACF field
- Include User ID in iFrame URL
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Wp_Schedule_Event every few minutes doesn’t work
- File from parent theme imported to child theme doesn’t work – any ideas?
- Outputting post content to jQuery .html() string
- shortcodes, custom php and their errors
- register_block_type is not working properly
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- How to center all text body in single.php at once?
- Access WP files on “server 1”, from “server 2” – using wp-load on an external website
- Remove node from multisites?
- How to include a function in a template with template tag
- wordpress all post filter by year
- How to add custom text near category/tag title in WordPress Twenty Fifteen Theme?
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Pulling a variable into the wp_nav_menu function
- Popular Post Not Show
- Echo multiple tasks if a common function exists
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Issues separating my Plugin pages into different files
- Problem with function.php.. like
- Echo get_option displays as text
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- How to extract URLs from wordpress taxonomies
- Warning: Illegal string offset ‘post’ and ‘page’
- Remove content links (internal and external), but exclude post at specific categories
- strict custom php script on specific product category [closed]
- Add adjacent post function inside custom recent post function
- Customize Notification Email Sent to New User When Manually Created by Site Administrator
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- How can I display a Divi content inside a modal based on an AJAX request
- Calling a PHP function from a menu item
- Custom update for Woocommerce stock quantity [closed]