Thumbnail + Excerpt = loss in word count

For everybody that is looking for a great excerpt that keep html tags in tact and want the excerpt not to cut off mid sentence and have a true word count, here is the code function pietergoosen_custom_wp_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ( ” == $text ) { $text = get_the_content(”); $text = … Read more

Remove Line Breaks From Cell Content in WordPress

The <br/> tags are added by wpautop function that is hooked into the_content filter. So you need to unhook it from the page where your table is displayed. There are several ways to do this. With PHP you can do something like this (change the ‘your_page/post_id’ with the actual ID) function wpdg_91929_remove_autop_for_page( $content ) { … Read more

Localizing a string with html tag with word inside that tag

Possible solution to get everything translatable as one sting. <?php printf(__(‘Click <a href=”https://wordpress.stackexchange.com/questions/135866/%s”>Here</a> to go and wacth the video.’, ‘pietergoosen’), esc_url( get_permalink() )); ?> It is usually safe to assume that the translator have enough knowledge of HTML to understand what is going on there.

Custom title widget / HTML encoding

As you know, html tags doesn’t work on widget title. But there’s work around to use it. The best approach i know is to use shortcode in title. So, for using br and span, the following is a solution – add_filter(‘widget_title’, ‘do_shortcode’); add_shortcode(‘br’, ‘wpse_shortcode_br’); function wpse_shortcode_br( $attr ){ return ‘<br />’; } add_shortcode(‘span’, ‘wpse_shortcode_span’); function … Read more

How to Embed HTML files directly into WordPress

It would really help to know exactly what you’re trying to achieve. The more you work with WordPress, the more the sentence “Necessity is the mother of invention” makes sense. A WordPress site is essentially snippets of html code put together with php. For example, header.php contains the instructions to build the header, the page … Read more

Preserve white-space in Page

You are not wrapping the code inside <code> tags. <pre> <code> selector { property: value; property: value; } </code> </pre> Furthermore, most syntax highlighting plugins also use this format (both <pre> and <code>) to render code. Here you have more about this. https://css-tricks.com/snippets/css/make-pre-text-wrap/