Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Adds a title attribute to iframe oembeds
*
* @since 1.0.0
*
* @param string $html HTML
* @param string $url URL to embed
* @param array $attributes HTML Attributes
* @param int $post_id Post ID
@simplethemes
simplethemes / scripts.php
Created October 23, 2017 16:21
Customize the ACF color picker in your theme
// add brand color palette to acf color picker
function kronos_acf_input_admin_footer() {
?><script type="text/javascript">
(function($) {
acf.add_filter('color_picker_args', function( args, $field ){
args.palettes = ["#000000","#CCCCCC","#EEEEEE","#FFFFFF","#b9ad33","#4c92af","#79c0a6"]
return args;
});
})(jQuery);
</script>
@hemusyl
hemusyl / breadcrumbs-custom.php
Last active December 23, 2024 16:41
WordPress custom breadcrumbs without plugin
http://www.qualitytuts.com/wordpress-custom-breadcrumbs-without-plugin/
Step 1
Breadcrumbs are the important part of our website, in wordpress there are several plugins are available for this, but below i posted
the code for custom breadcrumbs for our wordpress site. Just add this below code in to your current wordpress theme functions.php
and call the second step.
<?php
function qt_custom_breadcrumbs() {
@amboutwe
amboutwe / yoast_seo_canonical_change_woocom_shop.php
Last active March 6, 2025 17:20
Code snippets for the Yoast SEO canonical output
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change the canonical link for the shop page
* Credit: Scott Weiss of somethumb.com
* Yoast Doc: https://developer.yoast.com/features/seo-tags/canonical-urls/api/
* Last Tested: Jan 25 2017 using Yoast SEO 6.0 on WordPress 4.9.1
*/
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_woocom_shop', 10, 1 );
@ollietreend
ollietreend / acf-php-to-json.php
Last active February 11, 2025 14:00
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@lukecav
lukecav / DNS Prefetch domains
Last active October 9, 2024 00:30
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@amboutwe
amboutwe / wordpress_robots_custom.php
Last active April 2, 2025 14:22
Filters and example code for Yoast SEO robots or WP robots.txt
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: June 09 2020 using WordPress 5.4.1
*/
add_filter('robots_txt','custom_robots');
@lcdsantos
lcdsantos / wp-get_id_by_slug
Created February 1, 2017 13:57 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@amboutwe
amboutwe / yoast_seo_prev_next_change.php
Last active March 12, 2025 14:48
Remove or modify the Yoast SEO prev or next URLs. Only copy the section of code you need.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change Yoast SEO Prev/Next URL on some pages
* Credit: Yoast Team
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8
*/
add_filter( 'wpseo_next_rel_link', 'custom_change_wpseo_next' );
@mwangepatrick
mwangepatrick / functions.php
Created April 2, 2016 11:21
Setting the height of wysiwyg
add_action('acf/input/admin_head', 'lh_acf_admin_head');
function lh_acf_admin_head() {
?>
<style type="text/css">
.acf-editor-wrap iframe {
height: 150px !important;
min-height: 150px;
}
.acf-editor-wrap .mce-fullscreen iframe{