St. Johansen
asked 10 years ago

Hello,
I would like to hide the author, date and comments fields, but only for sticky posts.Do I have to edit the template.css? Please help.

1 Answers
Wilfred
answered 10 years ago

Hi St. Johansen.
To resolve this issue, please follow my instruction here:
1. Open file home.php in your site / wp-content / themes / your theme / home.php
Remove following code from line 5 to line 11 

if ( dw_wall_get_theme_option('cat_select') ) {
$cat_arr = dw_wall_get_theme_option('cat_select');
if ($cat_arr[0] != '-1') {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query( 'cat='.implode(',', $cat_arr).'&paged=' . $paged );
}
}

2. Open the file functions.php in your site / wp-content / themes / your theme / functions.php
Add following code at the bottom of the file.

if( ! function_exists('wallpress_alter_query') ) {
function wallpress_alter_query($query) {
//gets the global query var object
global $wp_query;
//gets the front page id set in options
$front_page_id = get_option('page_on_front');
if ( 'page' != get_option('show_on_front') || $front_page_id != $wp_query->query_vars['page_id'] || is_home() ) {
return;
}
if ( !$query->is_main_query() ) {
return;
}
if ( dw_wall_get_theme_option('cat_select') ) {
$cat_arr = dw_wall_get_theme_option('cat_select');
if ($cat_arr[0] != '-1') {
$query->set('cat', implode(',', $cat_arr) );
}
}
}
add_action('pre_get_posts','wallpress_alter_query');
}

3. Go to Dashboard / Appearance / Customize /Custom Code, and add this code below to Header Code section:

<style>
.sticky .meta-top,
.sticky .comments-link,
.sticky .item-permalink + .sep {
display: none;
}
</style>

Hope this helps.

Powered by DW Question & Answer Pro