How do I enable HTML5 prefetching on this page?

If I understand correctly you are putting that code in header.php, that is required in the file single-dress.php using get_header(), and in the same file, after about 2 dozen lines, you define the variables you used 2 dozen lines before. So, either your server has an embedded time machine, or your code can’t work. What … Read more

Execute only on a certain page

The is_page function accepts any of the page ID, the page title or the page slug. It looks like you’re trying to give it an URL fragment instead. You say that ‘contact-us’ is the page slug for your contact page, so try if (is_page(‘contact-us’)) { without the forward slashes, i.e. passing the page slug, instead.

Count Title and Post Characters

You can use this function wp_strip_all_tags. strlen( wp_strip_all_tags($post->post_content)); With that you get rid of all the HTML tags. Just a little extra detail, you might want to strip the shortcodes, too. You can use this function strip_shortcodes You will end up with something like this: strlen( wp_strip_all_tags(strip_shortcodes($post->post_content))); To convert the encoded entities to the corresponding … Read more

How do I put the homepage link inside the php _e code?

You are using PHP inside a single quote and a malformed one at that. That won’t work. Step one is to get that string right: _e( ‘The page you are looking for is not here. Why don’t you try the <a href=”‘.esc_url( home_url( “https://wordpress.stackexchange.com/” ) ).'”>homepage</a>?’, ‘braveandco’ ); That is pure PHP. Check PHP’s manual … Read more

Trim first 2 words of the exceprt

A more reliable way would be to filter the excerpt and to explode the string into an array, remove the first two key/value pairs from the array and then return your string add_filter( ‘wp_trim_excerpt’, function ( $text ) { // Make sure we have a text if ( !$text ) return $text; $text = ltrim( … Read more

String replace WordPress Site Title

Method 1 You can do this using JavaScript. First, add an id for your h1 tag. I will use mobId here so your header tag will look like this: <h1 class=”site-title” id=”mobId”>My Site Title – Is Great</h1> Then replace the hyphen with your desired code: <script> var myStr = document.getElementById(“mobId”).innerHTML; var newStr = myStr.replace(“-“, “<span … Read more

How to link to a custom .php page in my folder

WordPress doesn’t load templates that way. First: give the template a name: To load a page template, first you’ll have to make sure your template has a name. To do that, you’ll have to have the following CODE in your template file (here mypage.php): <?php /** * Template Name: My Page */ Once you have … Read more