wp
Aug 2, 2021
Create new wp user using the db
INSERT INTO `wp_monicarissler`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'tamberra', MD5('!!zest35TAM!!--'), 'tamberra', 'knoreika@tamberra.com', '', '', '', '0', 'tamberra);
INSERT INTO `wp_monicarissler`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
Apr 2, 2021
Disable Yoast features on function.php
// Remove multiple Yoast meta tags
add_filter( 'wpseo_canonical', 'remove_multiple_yoast_meta_tags' );
add_filter( 'wpseo_metadesc', 'remove_multiple_yoast_meta_tags' );
function remove_multiple_yoast_meta_tags( $myfilter ) {
if ( is_page ( 'about' ) ) { <-- FILTER BY SLUG
return false;
}
return $myfilter;
}To completely disable Yoast:
May 1, 2020
WP-CLI commands
Update WordPress via WP-CLI:
# wp core version
# wp core updateUpdate WordPress Plugins using WP-CLI
# wp plugin list
# wp plugin update <i>pluginname</i>Install and Activate WordPress Plugins & Themes via WP-CLI
# wp plugin install Plugin_Name
# wp plugin activate Plugin_NameMay 1, 2020
Install Wordpress cli
# cd /home/username
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
# chmod +x wp-cli.phar
# php wp-cli.phar --info
# echo "alias wp='~/wp-cli.phar'" >> .bashrc
# source .bashrcFeb 4, 2019
Add custom meta box with html and save to db
/*custom meta box Secondary Form*/
function custom_meta_box_markup($object) {
wp_nonce_field(basename(__FILE__), "meta-box-nonce");
?>
<div>
<?phpfunction wp1482371_custom_post_type_args( $args, $post_type ) {
if ( $post_type == "animal-species" ) {
$args['rewrite'] = array(
'slug' => 'animal'
);
}
return $args;
}
add_filter( 'register_post_type_args', 'wp1482371_custom_post_type_args', 20, 2 );Jan 18, 2019
Change Custom Post Type slug
The register_post_type_args filter can be used to modify post type arguments:
add_filter( 'register_post_type_args', 'wpse247328_register_post_type_args', 10, 2 );
function wpse247328_register_post_type_args( $args, $post_type ) {
if ( 'portfolio' === $post_type ) {
$args['rewrite']['slug'] = 'stories';
}
return $args;
}
Nov 26, 2018
Include page content into search result
//Include page content into search result
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'page'));
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');Oct 30, 2018
Wp - Insert a shortcode in template
<?php echo do_shortcode('[wcas-search-form]'); ?>Apr 6, 2018
Adding Categories and Tags to pages
function catgtopages_settings() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
register_taxonomy_for_object_type('category', 'page');
}
// Add to the admin_init hook of your theme functions.php file
add_action( 'init', 'catgtopages_settings' );