Skip to content

Instantly share code, notes, and snippets.

@Sstobo
Sstobo / gist:fe410434fb3de1b233800367695cab8e
Created November 14, 2017 21:23
[WP Plugin dev] #wp #plugins
function inhabitent_cpt_product() {
$args = array();
register_post_type( 'product', $args );
}
add_action( 'init', 'inhabitent_cpt_product' );
## FLUSH PERMALINK CACHE When adding new content type or templates OR HAVING PROBLEMS ##
go to settings on dash
permalinks ---> save
@Sstobo
Sstobo / gist:dd6a6670f0f782973678ea34c446e5a0
Created November 14, 2017 18:56
[Information Architecture] #ia
####### WAYS TO SORT TAXONOMYS ##########
Content audit : go through everything
ROT ANALYSIS: Redundant, out-dated or trivial?
Tree diagrams
Card sorting
######## Wordpress Taxonomies ###########
tags, categories, pages, posts
@Sstobo
Sstobo / gist:2660749890729425f8cc6c8464491e90
Created November 10, 2017 19:58
[WP filters and actions] . #php #wp #hooks #filters #actions
add_setup_theme . -order of initialization]
add_after
after_switch_theme . (action that happens IF a theme gets switched)
body_class
** excerpt_length - change length of custom excerpt (add to loop)
@Sstobo
Sstobo / gist:288ac5b82e27e1e3da5eb291ce52a7c4
Created November 10, 2017 17:59
[WP remove menus from build version] #build #wp #menu
What if we wanted to remove the Editor links from the Appearance/Plugins sub-menus so no internal end user can mess with code from inside WP?
// Remove "Editor" links from sub-menus
function inhabitent_remove_submenus() {
remove_submenu_page( 'themes.php', 'theme-editor.php' );
remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
}
add_action( 'admin_menu', 'inhabitent_remove_submenus', 110 );
The priority number is an optional integer value on a scale of 1 to 999 that determines the priority of order for functions tied to that specific hook.
@Sstobo
Sstobo / gist:b898671626ef36b754ad7fcd69bf7b08
Created November 10, 2017 17:52
[WP actions filters] #wp
Actions vs. Filters
Actions Filters*
Used when something has to be added/done Used when something has to be changed
Declared with do_action() Declared with apply_filters()
Used with add_action() Used with add_filter()
@Sstobo
Sstobo / gist:0abc488d9cdb9ecada0cb86289f2142f
Created November 10, 2017 00:51
[interviewing, job culture, resume]
https://redacademy-dev-van.slack.com/files/U75NWHJDR/F7Z2MG24X/ppd_notes.txt
@Sstobo
Sstobo / gist:8271af7d77e5e2dc742316d50c863568
Created November 9, 2017 19:31
[WP closing tags] #wp
Don't Forget!
When you build a WP theme, you want to make sure you include the following right before your closing <head> tag:
<!-- ...all of the <head> stuff above -->
<?php wp_head(); ?>
</head>
And this right before the closing body tag:
<!-- ...all of the <body> stuff above -->
Like our sidebars, we must "register" all of the navigation menus we want to add to our WordPress theme:
In your functions.php file:
function my_theme_setup() {
register_nav_menus( array(
'primary' => 'Primary Menu',
) );
}
add_action( 'after_setup_theme', 'my_theme_setup' );
@Sstobo
Sstobo / gist:bd6b751a6e6f3ad951b52ef973d633c2
Created November 9, 2017 19:21
[WP sidebar] #wp #sidebar
To create a widgetized area in a WordPress theme, in your functions.php file you will need to add:
function my_widgets_init() {
register_sidebar( array(
'name' => esc_html( 'Sidebar' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
@Sstobo
Sstobo / gist:3d1f52e0a025210ef34015ab7a51cbea
Created November 9, 2017 19:11
[WP comments template] #wp #comments #template
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>