Skip to content

Instantly share code, notes, and snippets.

Making things. All the things. Ahh!

Macario James macariojames

Making things. All the things. Ahh!
View GitHub Profile
macariojames / functions.php
Last active Nov 26, 2020
Change wp-login.php page title // Remove "WordPress" from login page
View functions.php
// Put this in your functions.php file
// Changes wp-login.php page title
// Here I'm removing the default "WordPress" at the end of it ~mj
function custom_login_title( $login_title ) {
return str_replace(array( ' &lsaquo;', ' &#8212; WordPress'), array( ' &lsaquo;', ''),$login_title );
add_filter( 'login_title', 'custom_login_title' );
macariojames / functions.php
Created Feb 21, 2020
Remove all classes from anchors in navwalker menus (WordPress)
View functions.php
//Put this in your functions.php or custom functionality plugin
// remove all classes from anchors in menus ~mj
function mj_remove_classes_from_all_menu_anchors( $atts ) {
$atts['class'] = ''; // not it's blank; if you add classes like 'example1 class2', it'll add classes ~mj
return $atts;
add_filter( 'nav_menu_link_attributes', 'mj_remove_classes_from_all_menu_anchors', 10 );
macariojames / mailchimp-custom.js
Last active Jan 30, 2020
MailChimp hide form on successful submit and thank you message; jQuery
View mailchimp-custom.js
// Add a surrounding <div> for all the ish don't want to keep once submission is successful
<script type='text/javascript' src='//'></script>
<script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]='FNAME';ftypes[1]='text';fnames[0]='EMAIL';ftypes[0]='email';}(jQuery));
//var $mcj = jQuery.noConflict(true);
$(".button").on("click", function(){
macariojames / external-links.js
Last active Jan 29, 2020
Add icon to all external links
View external-links.js
macariojames / remove-article-tag-yoast-wpseo-wordpress.php
Last active Sep 1, 2019
Remove article:tag meta from Yoast WordPress SEO plugin
View remove-article-tag-yoast-wpseo-wordpress.php
// Put in functions.php or custom functionality plugin.
// Remove article:tag meta that Yoast's WordPress SEO outputs ~mj
function remove_wpseo_fb_tags_categories() {
global $wpseo_og;
remove_action('wpseo_opengraph', array($wpseo_og, 'tags'), 16);
remove_action('wpseo_opengraph', array($wpseo_og, 'category'), 17);
add_action('wpseo_opengraph', 'remove_wpseo_fb_tags_categories');
macariojames / add-img-responsive-class-images-wordpress.php
Last active Sep 1, 2019
Add .img-responsive class to all images uploaded/added in WordPress
View add-img-responsive-class-images-wordpress.php
* @desc Add .img-responsive to all post images ~mj
function add_post_img_responsive_class($attr) {
$attr['class'] .= ' img-responsive'; // note the leading space
return $attr;
add_filter('wp_get_attachment_image_attributes', 'add_post_img_responsive_class');
macariojames / core-emails.php
Last active Sep 1, 2019
ACF Advanced Forms - Custom Reply-to
View core-emails.php
// add this to `core-emails.php` file in the ACF Advanced Forms plugin ~mj
// From header
$from = af_resolve_field_includes( $email['from'], $fields );
$replyto = af_get_field( 'email');
$headers[] = 'From:' . $from;
// only have reply-to to Customer if it's admin
macariojames / display-field-name-acf-admin.php
Last active Sep 1, 2019
Display field_name for ACF field names back-end in development if Administrator
View display-field-name-acf-admin.php
// Display ACF field names for development for Administrator only
function display_acf_field_names( $field ) {
echo $field['_name'];
if(is_admin() && !current_user_can('manage_options')) {
add_action( 'acf/render_field', 'display_acf_field_names', 10, 1 );
macariojames / get_real_host.php
Last active Sep 1, 2019
WordPress: Use different MySQL login credentials depending on your host (localhost, sandbox, production, etc.)
View get_real_host.php
/* I use this in a separate config-properties.php or otherwise named file
* which is then included by wp-config.php ~mj */
function getRealHost() {
list($realHost,) = explode(':',$_SERVER['HTTP_HOST']);
return $realHost;
macariojames / header.php
Last active Sep 1, 2019
WordPress redirect non-logged in user to a page/site
View header.php
// put this in header.php
if (!is_user_logged_in()) {
wp_redirect( '');
} ?>
You can’t perform that action at this time.