Skip to content

Instantly share code, notes, and snippets.

View khleomix's full-sized avatar

JC Palmes khleomix

View GitHub Profile
@khleomix
khleomix / .gitignore
Last active September 25, 2017 17:02
.gitignore file for git-managed WordPress projects.
# -----------------------------------------------------------------
# .gitignore for WordPress @khleomix for MavenTechSolutions.ph
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
#
# To ignore uncommitted changes in a file that is already tracked, use
# git update-index --assume-unchanged
#
# To stop tracking a file that is currently tracked, use
@khleomix
khleomix / style.css
Last active November 27, 2018 08:50
CSS Grid using Fractional Units
.container {
display: grid;
grid-template-columns: repeat(4, 1fr); /* this will create a 4 columns grid equal width */
/* grid-template-columns: 1fr 1fr 2fr; can also be used like this */
grid-template-rows: repeat(3, 100px); /* will create 3 rows with 100px height each */
grid-gap: 1em; /* will add gutters in between rows and columns at 1em each */
/* grid-gap: 1em 2em; 1em row gaps and 2em column gaps */
}
@khleomix
khleomix / README.md
Created December 28, 2018 16:15 — forked from hofmannsven/README.md
My simple Git Cheatsheet
@khleomix
khleomix / new_user.sql
Created May 26, 2019 06:09
Add new WP user via mysql
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('yourpassword'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
@khleomix
khleomix / nvmCommands.js
Created December 7, 2020 10:12 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list installed versions of node (via nvm)
nvm ls
// install specific version of node
nvm install 6.9.2
// set default version of node
@khleomix
khleomix / offset_pagination.php
Last active February 16, 2022 20:36
Pagination with Offset
<?php
/**
* Displays numeric pagination with offset.
*
* @param array $custom_query Custom WP_Query.
* @return void
* @author JC Palmes
*/
function display_numeric_pagination_with_offset( $custom_query ) {
@khleomix
khleomix / block-variations.php
Last active February 16, 2022 20:35
Block Variations
<?php
wp.blocks.registerBlockVariation(
'core/columns',
{
name: 'unicorn',
title: 'Unicorn',
isDefault: true, // will override core block and remove it from the inserter, set to false or remove to use as a separate block.
attributes: {
className: 'unicorn-columns',
},
@khleomix
khleomix / fix-pagination.php
Last active February 16, 2022 20:34
Fix for error 404 on last page If using custom pagination for custom post type and with different posts_per_page value from settings. Add to functions.php/queries.php
<?php
/**
* Fix pagination on archive pages
*
* @author JC Palmes
*/
function khleomix_remove_page_from_query_string( $query_string ) {
if ( isset( $query_string['name'] ) == 'page' && isset( $query_string['page'] ) ) {
unset( $query_string['name'] );
$query_string['paged'] = $query_string['page'];
@khleomix
khleomix / post_search.php
Last active February 16, 2022 20:34
get_posts() with search
<?php
$posts = new WP_Query( array( 's' => $search_string ) );
$posts = $posts->get_posts();
foreach( $posts as $post ) { /* ... */ }
Closes #
### Link
### Feature Description
### Feature Screenshots