Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to remove post info for a specific category
- This topic has 10 replies, 2 voices, and was last updated 9 years, 7 months ago by jasonHawk.
-
AuthorPosts
-
August 14, 2014 at 12:34 am #118714jasonHawkMember
Hello guys,
I wanted to remove post info on a specific category (single post that is in a certain category). I'm using the Epik theme by Appfinite which is a third party theme offered here in studiopress. Can you help me with this one? TIA!
regards... Jason
August 14, 2014 at 12:41 am #118716Genesis DeveloperMemberare you wanting to delete the info from category archive page or single post details page?
August 14, 2014 at 12:51 am #118717jasonHawkMemberI want to delete from single post details.
August 14, 2014 at 1:05 am #118718Genesis DeveloperMemberPlease add the following code in your functions.php file
add_filter( 'genesis_post_info', 'post_info_filter' ); function post_info_filter( $post_info ) { global $post; $exclude_cat_id = '46,39'; // You'll replace id with your category id if ( 'page' === get_post_type( $post->ID ) ) return; if( in_category ( $exclude_cat_id , $post ) ) return false; return $post_info }
Hope that it'll help you. Good Luck
August 14, 2014 at 1:24 am #118719jasonHawkMemberthanks man! trying it now!
August 14, 2014 at 1:26 am #118720Genesis DeveloperMemberoops...I did wrong. Please add
;
at end of this linereturn $post_info
.
August 14, 2014 at 11:45 pm #118910jasonHawkMemberHi there genwrock,
I can't make your code work..
regards,
JasonAugust 14, 2014 at 11:56 pm #118912Genesis DeveloperMemberI tested my code. It is working.
August 15, 2014 at 12:05 am #118913jasonHawkMemberThis is the code I inserted,
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter( $post_info ) {
global $post;
$exclude_cat_id = '1';if ( 'page' === get_post_type( $post->ID ) )
return;if( in_category ( $exclude_cat_id , $post ) )
return false;return $post_info;
}regards,
JasonAugust 15, 2014 at 12:18 am #118915Genesis DeveloperMemberOk. try this
add_filter( 'genesis_post_info', 'post_info_filter' ); function post_info_filter( $post_info ) { global $post; $exclude_cat_id = array(1); if ( 'page' === get_post_type( $post->ID ) ) return; if( in_category ( $exclude_cat_id , $post ) ) return false; return $post_info; }
Please use the Notepad when you are editing the file. Otherwise single quote
'
is creating the issue.
August 15, 2014 at 12:46 am #118920jasonHawkMemberStill can't make it work... such a noob! haha here is the complete functions.php
<?php
//* Start the engine
require_once( get_template_directory() . '/lib/init.php' );//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Epik Theme', 'epik' );
define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/epik/' );//* Enqueue Lato Google font
add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
function genesis_sample_google_fonts() {
wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css?family=Open+Sans:300,400,700', array(), PARENT_THEME_VERSION );
}//* Add HTML5 markup structure
add_theme_support( 'html5' );//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );//* Add support for custom background
add_theme_support( 'custom-background' );// Create additional color style options
add_theme_support( 'genesis-style-selector', array(
'epik-black' => __( 'Black', 'epik' ),
'epik-blue' => __( 'Blue', 'epik' ),
'epik-darkblue' => __( 'Dark Blue', 'epik' ),
'epik-gray' => __( 'Gray', 'epik' ),
'epik-green' => __( 'Green', 'epik' ),
'epik-orange' => __( 'Orange', 'epik' ),
'epik-pink' => __( 'Pink', 'epik' ),
'epik-purple' => __( 'Purple', 'epik' ),
'epik-red' => __( 'Red', 'epik' ),
) );// Add support for custom header
add_theme_support( 'genesis-custom-header', array(
'width' => 360,
'height' => 164
) );// Add new image sizes
add_image_size( 'featured-img', 730, 420, TRUE );
add_image_size( 'featured-page', 341, 173, TRUE );
add_image_size( 'portfolio-thumbnail', 264, 200, TRUE );// Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'inner', 'footer-widgets', 'footer' ) );// Reposition the Secondary Navigation
remove_action( 'genesis_after_header', 'genesis_do_subnav' ) ;
add_action( 'genesis_before_header', 'genesis_do_subnav' );// Before Header Wrap
add_action( 'genesis_before_header', 'before_header_wrap' );
function before_header_wrap() {
echo '<div class="head-wrap">';
}// Reposition the Primary Navigation
remove_action( 'genesis_after_header', 'genesis_do_nav' ) ;
add_action( 'genesis_after_header', 'genesis_do_nav' );// After Header Wrap
add_action( 'genesis_after_header', 'after_header_wrap' );
function after_header_wrap() {
echo '</div>';
}// Customize search form input box text
add_filter( 'genesis_search_text', 'custom_search_text' );
function custom_search_text($text) {
return esc_attr( 'Search...' );
}add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter( $post_info ) {
global $post;
$exclude_cat_id = array(2);if ( 'page' === get_post_type( $post->ID ) )
return;if( in_category ( $exclude_cat_id , $post ) )
return false;return $post_info;
}add_action( 'admin_menu', 'epik_theme_settings_init', 15 );
/**
* This is a necessary go-between to get our scripts and boxes loaded
* on the theme settings page only, and not the rest of the admin
*/
function epik_theme_settings_init() {
global $_genesis_admin_settings;add_action( 'load-' . $_genesis_admin_settings->pagehook, 'epik_add_portfolio_settings_box', 20 );
}// Add Portfolio Settings box to Genesis Theme Settings
function epik_add_portfolio_settings_box() {
global $_genesis_admin_settings;add_meta_box( 'genesis-theme-settings-epik-portfolio', __( 'Portfolio Page Settings', 'epik' ), 'epik_theme_settings_portfolio', $_genesis_admin_settings->pagehook, 'main' );
}/**
* Adds Portfolio Options to Genesis Theme Settings Page
*/
function epik_theme_settings_portfolio() { ?><p><?php _e("Display which category:", 'genesis'); ?>
<?php wp_dropdown_categories(array('selected' => genesis_get_option('epik_portfolio_cat'), 'name' => GENESIS_SETTINGS_FIELD.'[epik_portfolio_cat]', 'orderby' => 'Name' , 'hierarchical' => 1, 'show_option_all' => __("All Categories", 'genesis'), 'hide_empty' => '0' )); ?></p><p><?php _e("Exclude the following Category IDs:", 'genesis'); ?><br />
<input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_cat_exclude]" value="<?php echo esc_attr( genesis_get_option('epik_portfolio_cat_exclude') ); ?>" size="40" /><br />
<small><?php _e("Comma separated - 1,2,3 for example", 'genesis'); ?></small></p><p><?php _e('Number of Posts to Show', 'genesis'); ?>:
<input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_cat_num]" value="<?php echo esc_attr( genesis_option('epik_portfolio_cat_num') ); ?>" size="2" /></p><p><span class="description"><?php _e('<b>NOTE:</b> The Portfolio Page displays the "Portfolio Page" image size plus the excerpt or full content as selected below.', 'epik'); ?></span></p>
<p><?php _e("Select one of the following:", 'genesis'); ?>
<select name="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_content]">
<option style="padding-right:10px;" value="full" <?php selected('full', genesis_get_option('epik_portfolio_content')); ?>><?php _e("Display post content", 'genesis'); ?></option>
<option style="padding-right:10px;" value="excerpts" <?php selected('excerpts', genesis_get_option('epik_portfolio_content')); ?>><?php _e("Display post excerpts", 'genesis'); ?></option>
</select></p><p><label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_content_archive_limit]"><?php _e('Limit content to', 'genesis'); ?></label> <input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_content_archive_limit]" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_content_archive_limit]" value="<?php echo esc_attr( genesis_option('epik_portfolio_content_archive_limit') ); ?>" size="3" /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[epik_portfolio_content_archive_limit]"><?php _e('characters', 'genesis'); ?></label></p>
<p><span class="description"><?php _e('<b>NOTE:</b> Using this option will limit the text and strip all formatting from the text displayed. To use this option, choose "Display post content" in the select box above.', 'genesis'); ?></span></p>
<?php
}//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );// Register widget areas
genesis_register_sidebar( array(
'id' => 'slider-wide',
'name' => __( 'Slider Wide', 'epik' ),
'description' => __( 'This is the wide slider section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'slider',
'name' => __( 'Slider', 'epik' ),
'description' => __( 'This is the slider section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-wide',
'name' => __( 'Welcome Wide', 'epik' ),
'description' => __( 'This is the Wide (full width) section of the Welcome area.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-feature-1',
'name' => __( 'Welcome Feature #1', 'epik' ),
'description' => __( 'This is the first column of the Welcome feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-feature-2',
'name' => __( 'Welcome Feature #2', 'epik' ),
'description' => __( 'This is the second column of the Welcome feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-feature-3',
'name' => __( 'Welcome Feature #3', 'epik' ),
'description' => __( 'This is the third column of the Welcome feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-1',
'name' => __( 'Home Feature #1 (Left)', 'epik' ),
'description' => __( 'This is the first column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-2',
'name' => __( 'Home Feature #2 (Right)', 'epik' ),
'description' => __( 'This is the second column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-3',
'name' => __( 'Home Feature #3 (Gray)', 'epik' ),
'description' => __( 'This is the 3rd column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-4',
'name' => __( 'Home Feature #4 (White)', 'epik' ),
'description' => __( 'This is the 4th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-5',
'name' => __( 'Home Feature #5 (Dark Gray)', 'epik' ),
'description' => __( 'This is the 5th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-6',
'name' => __( 'Home Feature #6 (White)', 'epik' ),
'description' => __( 'This is the 6th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-7',
'name' => __( 'Home Feature #7 (Gray)', 'epik' ),
'description' => __( 'This is the 7th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-8',
'name' => __( 'Home Feature #8 (White)', 'epik' ),
'description' => __( 'This is the 8th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-9',
'name' => __( 'Home Feature #9 (Gray)', 'epik' ),
'description' => __( 'This is the 9th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-10',
'name' => __( 'Home Feature #10', 'epik' ),
'description' => __( 'This is the 10th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-11',
'name' => __( 'Home Feature #11', 'epik' ),
'description' => __( 'This is the 11th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-12',
'name' => __( 'Home Feature #12', 'epik' ),
'description' => __( 'This is the 12th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-13',
'name' => __( 'Home Feature #13', 'epik' ),
'description' => __( 'This is the 13th column of the feature section of the homepage.', 'epik' ),
) );
genesis_register_sidebar( array(
'id' => 'home-feature-14',
'name' => __( 'Home Feature #14 (White)', 'epik' ),
'description' => __( 'This is the 14th column of the feature section of the homepage.', 'epik' ),
) ); -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.