Skip to content

Instantly share code, notes, and snippets.

View DigitalEssence's full-sized avatar

Hedley Phillips DigitalEssence

View GitHub Profile
@DigitalEssence
DigitalEssence / WordPress - PHP - Add og Open Graph data to header
Created March 14, 2019 17:19
WordPress - PHP - Add og Open Graph data to header
//Add Open Graph
add_action('wp_head', 'fb_opengraph');
function fb_opengraph() {
if( is_single() || is_page() ) {
echo '
<meta property="og:title" content="Osso Restaurant - Peebles" />
<meta property="og:description" content="Osso Restaurant Peebles - Michelin Bib Gourmand Winner 2011 to 2018" />
<meta property="og:image" content="https://www.ossorestaurant.com/wp-content/uploads/2019/03/facebook-og-image.jpg" />';
}
}
@DigitalEssence
DigitalEssence / WordPress - MYSQL - Delete all post revisions from database
Created March 13, 2019 14:37
WordPress - MYSQL - Delete all post revisions from database
DELETE FROM wp_posts WHERE post_type = "revision";
@DigitalEssence
DigitalEssence / WordPress - Debug Pending Updates
Created March 4, 2019 11:33
WordPress - Debug Pending Updates
/**
* Debug Pending Updates
* Displays hidden plugin and theme updates on update-core screen.
*/
function debug_pending_updates() {
// Rough safety nets
if ( ! is_user_logged_in() || ! current_user_can( 'update_plugins' ) || ! current_user_can( 'update_themes' ) ) return;
$output = "";
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Add Div using functionand add_action
Created February 18, 2019 17:16
WordPress - Enfold - PHP - Add Div using functionand add_action
// Simple function to add a div
// Note, the display is set to none so it is only visible in the source code
function custom_stuff(){
?>
<div style="display:none">Find this</div>
<?php
}
add_action('wp_footer', 'custom_stuff');
@DigitalEssence
DigitalEssence / DigitalEssence - WordPress - CSS - Add transparent overlay
Last active February 18, 2019 17:15
- WordPress - CSS - Add transparent overlay
.div-to-have-overlay {
background: #fff;
height: 100%;
width: 100%;
opacity: 0.5;
top: 0;
left: 0;
position: absolute;
padding: 0;
transition: opacity .5s;
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Check if a post date is in the past
Last active February 18, 2019 12:47
WordPress - Enfold - PHP - Check if a post date is in the past
// For Enfold copy /enfold/config-templatebuilder/avia-shortcodes/postslider.php
// to /child-theme/shortcodes/postslider/postslider.php
// Add this query
if (strtotime(get_the_date( "Y-m-d", $the_id )) < strtotime(date("Y-m-d"))) {
//Do something
}
else {
//Do nothing
}
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Display current date in socket
Last active February 15, 2019 10:52
WordPress - Enfold - PHP - Display current date in socket
// Add dynamic date in Socket Copyright
// Add to functions.php
// Place [year] in socket
function year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'year_shortcode');
@DigitalEssence
DigitalEssence / WordPress - Enfold - PHP - Change element to full width under x pixels
Created February 13, 2019 17:13
WordPress - Enfold - PHP - Change element to full width under x pixels
@media only screen and (max-width: 1170px)
{
/*Make the programme left col become full width under 1170px*/
.homepage-blog-section-left-col {
display:block!important;
width:100%!important;
}
}
@DigitalEssence
DigitalEssence / WordPress - Enfold PHP - Restrict Post Previous and Next buttons to within its Category
Created March 29, 2018 15:45
WordPress - Enfold PHP - Restrict Post Previous and Next buttons to within its Category
//Restrict next<>previous links to within its own category
add_filter('avia_post_nav_settings', 'avia_post_nav_settings_mod');
function avia_post_nav_settings_mod($settings)
{
$settings['same_category'] = true;
return $settings;
}
#header .main_menu .avia-menu-fx {display: none !important;}