please help!!! this plugin to exclude Pages from the Front Page does not work.
Posted
by souravran
on Stack Overflow
See other posts from Stack Overflow
or by souravran
Published on 2010-03-27T06:13:22Z
Indexed on
2010/03/27
6:23 UTC
Read the original article
Hit count: 278
add_action('admin_menu', 'pag_admin_menu');
add_filter('wp_list_pages_excludes','exclude_PAG');
function pag_admin_menu()
{
add_options_page('Exclude', 'Exclude Page', 'administrator', 2, 'Pages');
}
function Pages()
{
if( $_POST[ 'xclu_pag' ] )
{
$message = process_PAG();
}
$options = PAG_get_options();
?>
<div class="wrap">
<h2>Exclude Categories</h2>
<?php //echo $message ?>
<p>Use this page to select the pages you want to exclude.</p>
<form action="" method="post">
<table width="960px">
<thead>
<tr>
<th scope="col">Category</th>
<th scope="col" align="left">Exclude from Front Page.</th>
</tr>
</thead>
<tbody id="the-list">
<?php
//print_r( get_categories() );
$pags = get_pages();
//echo $pags;
$temp_pag = 0;
foreach( $pags as $pag )
{
?>
<tr<?php if ( $temp_pag == 1 ) { echo ' class="alternate"'; $temp_pag = 0; } else { $temp_pag = 1; } ?>>
<th scope="row"><?php echo $pag->post_title; ?></th>
<td>
<input type="checkbox" name="exclude_paggg[]" value="-<?php echo $pag->ID ?>" <?php if ( in_array( '-' . $pag->ID, $options['exclude_paggg'] ) ) { echo 'checked="true" '; } ?>/>
</td>
</tr>
<?php
}
?>
</table>
<p class="submit"><input type="submit" value="Save Changes" /></p>
<input type="hidden" name="xclu_pag" value="true" />
</form>
</div>
<?php
}
function process_PAG()
{
if( !$_POST[ 'exclude_paggg' ] ) {
$_POST[ 'exclude_paggg' ] = array();
}
$options['exclude_paggg'] = $_POST[ 'exclude_paggg' ];
update_option('PAGExcludes', $options);
$message_pag = "<div class='updated'><p>Excludes successfully updated</p></div>";
// return $message_pag; }
function PAG_get_options() { $defaults = array(); $defaults['exclude_paggg'] = array(); $options = get_option('PAGExcludes'); if (!is_array($options)) { $options = $defaults; update_option('PAGExcludes', $options); } return $options; }
function exclude_PAG($query_pag) { $options = PAG_get_options(); if ($query_pag->is_home) { $query_pag->set('pag', implode( ', ', $options[ 'exclude_paggg' ] ) ); }
return $query_pag;
}
Where should I make any change to make it work to exclude pages from the front page..? INPUT WOULD BE GREATLY APPRECIATED....!! enter code here
© Stack Overflow or respective owner