Skip to content

Instantly share code, notes, and snippets.

<?php
function bit_crp_add_fields( $fields, $post_id ) {
global $wpdb;
$match_title = strip_tags( get_the_title( $post_id ) );
$match_content = bit_get_the_matcher($post_id);
$field_score = ", ( ( MATCH($wpdb->posts.post_title) AGAINST ('%s') *5 ) + ( MATCH($wpdb->postmeta.meta_value) AGAINST ('%s') *10 ) ) as score ";
$field_score = $wpdb->prepare( $field_score, $match_title, $match_content ) ;
@froutsis
froutsis / functions.php
Created April 4, 2018 14:05
Hook wpseo_breadcrumb_links to override category breadcrumbs
function custom_override_yoast_breadcrumb_trail( $links ) {
global $post;
if ( is_singular() ) {
$bit_term_key = 0;
$bit_parent_page = 0;
foreach ( $links as $key => $link ) {
// Is there a term / category within a breadcrumn in a singular post
@froutsis
froutsis / db-error.php
Last active March 2, 2016 14:29
db-error.php file for custom action on Error Establishing Connection on a Wordpress site. Uses SMTP Credentials. Add this after you set the correct settings in the wp-content folder of your wordpress installation.
<?php
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 600' );
$temp = mysql_error();
$url = curPageURL();