Skip to content

Instantly share code, notes, and snippets.

View SahinU88's full-sized avatar
🏠
Working from home

Şahin SahinU88

🏠
Working from home
View GitHub Profile
@amboutwe
amboutwe / yoast_seo_title_change-variable.php
Last active May 23, 2022 17:09
Change existing or add custom title or meta template variables
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Change existing title or meta template variable
* Credit: Moshe Harush
* https://stackoverflow.com/questions/36281915/yoast-seo-how-to-create-custom-variables
* Last Tested: Unknown
*/
// define the wpseo_replacements callback
function filter_wpseo_replacements( $replacements ) {
function logTimes(message) {
performance.mark(message); // this one is for WebPageTest
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools
console.info(message, performance.now()); // this is for the console, duh
// this here is for Google Analytics
ga('send', {
hitType: 'timing',
timingCategory: 'Performance',
timingVar: message,
@amboutwe
amboutwe / yoast_seo_breadcrumb_add_woo_shop.php
Last active March 15, 2024 14:55
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@amboutwe
amboutwe / yoast_seo_opengraph_change_image_size.php
Last active January 11, 2024 20:48
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
@mattclements
mattclements / function.php
Last active April 16, 2024 17:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Zenger
Zenger / wp_insert_post.php
Created November 11, 2013 11:07
wp_insert_post and WPML
<?php
global $wpdb;
// Insert the original post
$original = wp_insert_post($array, true);
// Insert the translated post
$translated = wp_insert_post($array, true);
// Make some updates to both translations