Split titles by the ” – ” in WordPress

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]); // … Read more

Adding a variable to some PHP code with gettext

Use sprintf(): // Translators: %s: author’s current year. esc_html( sprintf( __(‘Rates %s in &euro;/ week:’,’mysite-plugin’), $current_year ) ); This is a common pattern that can be found in WordPress core. The Translators: comment is also essential to provide translators with context to translate the passage and understand what the placeholder %s will contain.

Upgraded php & wordpress but theme broke

<?php the_post_thumbnail(thumbnail); ?> should be <?php the_post_thumbnail( “thumbnail” ); ?>. thumbnail is not a defined constant, and the updated version of PHP is no longer converting undefined constants into strings for you. It appears that PHP changed the “undefined constants” message from a notice to a fatal error sometime around version 8.

Unable to remove action from parent theme via child theme

The child theme’s functions.php is loaded before the parent theme’s functions.php: Unlike templates and patterns, the functions.php file of a child theme does not override the functions.php file in the parent theme. In fact, they are both loaded, with the child being loaded immediately before the parent. Source: https://developer.wordpress.org/themes/advanced-topics/child-themes/#using-functions-php This means that when the child … Read more

“Cannot start session when headers already sent” when attempting session

It turns out not all hosts treat sessions alike. I ended up scraping altogether the “session” code in functions.php previously referred to which was doing nothing. Instead, I added session_start() at the top of every template adding or retrieving a value from a name/value hash in $_SESSION. So, <?php session_start(); $_SESSION[‘order_id’] = $order_id; . . … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş