Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: “Custom” rewrite rule for static pages

I’ve created something like this:

function page_link( $page_number ) {
echo apply_filters('page_link', get_page_link( $page_number ) );
}

function get_page_link( $page_number ) {
$rewrite = bb_get_option( 'mod_rewrite' );
if ( $rewrite ) {
global $bbdb, $bb, $page;
$page = $page_number;

if ( $rewrite === 'slugs' ) {
$table_name = $bbdb->prefix . "pages";
$query = $bbdb->get_results("SELECT page_slug FROM $table_name WHERE page_id=".$page."");

foreach ($query as $rk) {
$column = $rk->page_slug;
}
} else {
$table_name = $bbdb->prefix . "pages";
$query = $bbdb->get_results("SELECT page_id FROM $table_name WHERE page_id=".$page."");

foreach ($query as $rk) {
$column = $rk->page_id;
}
}
$link = bb_get_option( 'uri' ) . "page/" . $column;
} else {
$args = array();
$link = bb_get_option( 'uri' ) . 'page.php';
$args['page_id+id'] = $page;
$args['part'] = 1 < $part ? $part : false;
$link = add_query_arg( $args, $link );
}

return apply_filters( 'get_page_link', $link, $page_number );
}

Trust me, I don’t know what this is either ;). I’m working on this for a couple of hours (in total) and I’ve messed up. Could someone help me in this by explaining how this thing should look like?

I mean – the above code is allowing me to type

<?php echo page_link("1"); ?>

and this will display url to static page with id=1, creating something like domain.com/page/1 or domain.com/page/about – so links are working. But now I want to send page ID to other functions that are selecting and displaying date from database – and I have no idea how to send this id in ‘rewrited’ version. Can anyone help?

Skip to toolbar