WordPress 4.5 Custom Logo API: Getting the logo URL

WordPress 4.5 is here with a new API for a Custom Logo.

Just by adding an add_theme_support like this:  add_theme_support('custom-logo');
Remember it’s best called in the after_setup_theme hook.

So now you’ll have a logo selector in your themes customiser.  You can then use the following to detect the logo, echo the logo or return the logo as a string:

Great I hear you say.  But what if you want to use the image as a background? get_custom_logo() returns the full <img /> tag.

After a bit of digging I found the image ID is stored as a modification for the theme, and retrieve it with this:
$custom_logo_id = get_theme_mod( 'custom_logo' );

Once you have the ID you can get the url and other info as normal with wp_get_attachment_image_src.
$logo_meta = wp_get_attachment_image_src($custom_logo_id,'full');

You can wrap this all up in a nice little function.

function get_custom_logo_src() {
    if (has_custom_logo()) {
        $custom_logo_id = get_theme_mod( 'custom_logo' );
        $logo_meta = wp_get_attachment_image_src($custom_logo_id,'full');
        return $logo_meta[0];
    } else {
        return false;

Hope this helps!

Search Relevance 2.0

Search relevance has been updated to 2.0 adding new features to control the display of  relevance score, highlighting search terms and custom excerpts focused on the relevant part of the post.

Still giving you amazingly relevant search results, out of the box, without the need for complicated indexing.

If you have any ideas/requests for simple features to add, just hit that comment button now!  Just remember I want to keep this nice and lightweight and simple to use 😉

Reviews have already started to come in – and they’re looking good!
Over at  http://www.echodesplugins.li-an.fr/plugins/search-relevance/ Li-An said

A little comparison with Relevanssi shows me a gain of 1.5 seconds on the results page of my most used word. This is for now, in my opinion, the most interesting alternative to the default search WP for people who are looking for quick results.


WordPress Developer Debug.

When developing themes and plugins for WordPress I often find myself with the dreaded white page – or just half a page with no useful error information.

You may already know about the WP_DEBUG constant, if you don’t its found in your wp_config.php file and you just change it to…

define('WP_DEBUG', true);

to turn it on debugging.
Chances are that with this turned on your WordPress will start spewing out a load of warnings you never even knew were happening!

This ‘error noise’ is fine for a development site. But what about if your site is live and need to code a new feature?

I came up with this little trick so I can turn on debug mode in the page request.

$debugmodeon = false;
if (isset($_GET['debug'])) {
	if ($_GET['debug'] != "") { 
		$debugmodeon = true;
define('WP_DEBUG', $debugmodeon);

Just add ?debug=true and voilà – debugging info only when you need it 😉

Once your done – you’ll want to swap back to define('WP_DEBUG', false); so your ‘debug mode’ can’t be triggered by accident..

WordPress Fixes: Showing content – not excerpt in searches.

Came across this one and it took a little tracking down to fix - so in case someone else has this issue - heres how i fixed it 😉

Came across this one and it took a little tracking down to fix – so in case someone else has this issue – here’s how I fixed it 😉

The Problem…

Search result pages in WordPress are showing a generated snippet from the post content, not the excerpt.   After confirming that the post does indeed have a custom excerpt specified for it, here’s what I did next…


First thing to do is the check is that you are using the_excerpt() in your template.  Look in your /wp-content/themes/[yourtheme] folder for search.php or if that’s not there – index.php.

In that file find the wordpress loop – it’ll start like this…
while (have_posts()) : the_post();

Make sure it has the_excerpt(); not the_content();, it could be like this

<?php if (is_archive() || is_search()) { ?>
    <?php the_excerpt(); ?>
<?php } else { ?>
    <?php the_content(); ?>
<?php } ?>

If you can see the_excerpt() – chances are you have the right template.


Once you’ve confirmed the templates is correct and the post has an excerpt, then you need start disabling plugins.
If possible turn them all off – then enable one at a time till you find the offender.
If it still happens with all plugins disabled, then its definitely your theme that’s to blame.

For me..

In my case the problem turned out to be (obviously with hindsight) Relevanssi. Relevanssi has an option to reformat your search result content to show the relevant result. This most likely results in a part of the content being shown – not the excerpt you specified. Its just a tickbox away to fix (Create custom search result snippets) 😉

Hope this helps save someone some time debugging!