Skip to content

Instantly share code, notes, and snippets.

Eric (shamai) Greenfield saltnpixels

Block or report user

Report or block saltnpixels

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@saltnpixels
saltnpixels / dynamic_url_nav_menu_url.php
Last active Apr 14, 2016
add dynamic url to menu item to wp nav menu with replacement strings
View dynamic_url_nav_menu_url.php
/*--------------------------------------------------------------
# add dynamic profile link to main menu. smart and simple! just do a string replace on a menu link item
# add a link item and set the url to --url-- and give it a css class of iscurrent
--------------------------------------------------------------*/
function wp_dynamic_profile_link( $menu ){
//$link may have to be changed to your current users profile or author page or whatever...
//i had a post type profile link to each user
@saltnpixels
saltnpixels / ajax_wp_query
Created Apr 10, 2016
ajax with wp_query
View ajax_wp_query
//put into functions
// AJAX receiver function
function get_my_ajax_stuff() {
// If there's a POST and a nonce set, verify the nonce to make sure this request is coming from the right place
if ( $_POST && isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'my_nonce_action' ) ) {
// Initialize
$results = array();
// Do something here to get some data (sanitize user input as needed)
$articles = new WP_Query(array(
@saltnpixels
saltnpixels / add_login_to_menu.php
Created Nov 16, 2015
adds login menu item to navigation
View add_login_to_menu.php
//add login to nav menu. wordpress example doesnt work! needed to play with it. login menu item added!
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if ($args->theme_location == 'primary') {
$loginout = '<li class="nav-menu menu-item loginout login-icon">' . wp_loginout($_SERVER['REQUEST_URI'], false ) . '</li>';
$items .= $loginout;
return $items;
}
else
View get_taxonomy_name.php
global $wp_query;
$term = $wp_query->get_queried_object();
$title = $term->taxonomy;
//var_dump $term to see all the stuff you can get
//if its a tag we want Tag not post_tag.... its the slug...
if($title == 'post_tag'){
echo 'Tag';
}
else{
echo ucwords( $title);
You can’t perform that action at this time.