WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Feb 18 2012

Uncornered Market (coming soon…)

Written by Travis Smith · Categorized: Portfolio

Feb 18 2012

002houston Magazine

Written by Travis Smith · Categorized: Portfolio

Feb 18 2012

Pinkalicious

Written by Travis Smith · Categorized: Portfolio

Feb 14 2012

How to Hide the Featured Image of a Specific Category on the Blog Page in Genesis

So, in case you forgot, in Genesis Featured Images can be added to the blog page by selecting the checkbox "Include the Featured Image?" in Genesis > Theme Settings > Content Archives (admin url: http://domain.com/wp-admin/admin.php?page=genesis#genesis-theme-settings-posts).

Genesis Content Archives
Click for Larger Image

So what if you wanted to remove the featured images of a specific category (say category ID 126 [to get the category ID, use a plugin called Simply Show IDs--makes it quite easy!])?

Here is what I did:

  1. Copied page_blog.php from the genesis directory, which only contains genesis() function call.
  2. Then added the following function.

[php]
add_action( 'genesis_before_post' , 'wps_no_feature_image' );
add_action( 'genesis_after_post_content' , 'wps_no_feature_image' );
/*
* Remove Featured Image from Small Group Show category on blog page
* @author Travis Smith
*
*/
function wps_no_feature_image() {
global $post;

if ( has_category( 126 , $post ) && 'genesis_before_post' == current_filter() )
remove_action( 'genesis_post_content', 'genesis_do_post_image' );
elseif ( has_category( 126 , $post ) && 'genesis_after_post_content' == current_filter() )
add_action( 'genesis_before_post_content', 'genesis_do_post_image' );
}
[/php]

First and foremost, we cannot simply remove the action and keep going because then it will be unhooked for all categories on that page after. So what's happening here?

Now, the Genesis Featured Image appears on the genesis_post_content hook. So I need to call my function before that hook (or earlier in priority) to remove that action. So I call the function on genesis_before_post which occurs before genesis_post_content. Then after I pass genesis_post_content hook, I need to add the action back for the next post.

So, if I am illustrating this, it's as though I am walking down the hallway approaching a hook with a hat that I was going to put on my head. Before I get to the hook, my brother takes the hat, and after I pass the hook, my brother puts the hat back on the hook for the next person.

Written by Travis Smith · Categorized: Genesis

Feb 10 2012

How to Get All Users of a Specific Role

WordPress Users
Recently, I needed to get all users of a certain role to modify a Comments Widget to remove those. Since WordPress 3.1, WordPress has made this quite easy to do now.

[php]
function wps_get_users_of_role( $role ) {
$wp_user_search = new WP_User_Query( array( 'role' => $role ) );
return $wp_user_search->get_results();
}
[/php]

This will give you an array that contains the following in an object:
[php]<pre>stdClass Object
(
[ID] => 1
[user_login] => username
[user_pass] => serialized PASSWORD
[user_nicename] => mynicename
[user_email] => [email protected]
[user_url] => http://mydomain.com
[user_registered] => GMT Time Stamp
[user_activation_key] => Something funky!
[user_status] => 0
[display_name] => My Display Name
)</pre>
[/php]

You can even set a predefined array and get only necessary information.

[php]
$args = array();
$args[0] = 'user_login';
$args[1] = 'user_nicename';
$args[2] = 'user_email';
$args[3] = 'user_url';
$wp_user_search = new WP_User_Query( array( 'role' => 'editor', 'fields' => $args ) );
$editors = $wp_user_search->get_results();
[/php]

Here's the result:
[php]<pre>stdClass Object
(
[user_login] => wpsmith
[user_nicename] => wpsmith
[user_email] => [email protected]
[user_url] =>
)</pre>
[/php]

Written by Travis Smith · Categorized: WordPress

  • « Previous Page
  • 1
  • …
  • 23
  • 24
  • 25
  • 26
  • 27
  • …
  • 60
  • Next Page »

Need Help?

Please let us know how we can help you!

Get Help

Recommendations

Genesis WordPress Framework
Sucuri Security
Gravity Forms
GetSoliloquy
Get Envira
Scribe SEO
BackupBuddy
WordPress Video User Manuals

Recent Posts

  • Solving WordPress 5XX Server Errors on SiteGround
  • Hiding an User in the WordPress Admin
  • Custom Rewrite Rules for Custom Post Types and Taxonomies
  • WordPress JavaScript Manager Native Functions
  • Causes of WordPress Site Performance Slowdown

About Travis

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in