Make a new file and include a page template to structure the loop and display your bookmarks.
<?php
/**
* Template Name: Bookmarked Page
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
Then just make sure a page exists called bookmarked (so the url is in place) and set it’s template to the custom page template you created.
You can also write a template to target a specific page.
- page-{slug}.php
- page-{ID}.php
is_bookmarked_page()
isn’t really required because you will already know your template is being used. There are however page template functions that could help.
get_page_template ()
wp_get_theme()->get_page_templates()
is_page_template()
get_page_template_slug()
It’s also possible to construct this page automatically after_switch_theme by creating the page using wp_insert_post and setting the template with update_post_meta.
Create the page if it doesn’t already exist:
$title = __( 'Bookmarks' );
if ( NULL == get_page_by_title( $title ) ) {
$post_id = wp_insert_post(
array(
'post_name' => 'bookmarked',
'post_title' => $title,
'post_content' => '',
'post_type' => 'page',
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_status' => 'publish',
)
);
}
Set the page template:
$template_full_path = trailingslashit( get_stylesheet_directory() ) . $template_rel_path;
if ( file_exists( $template_full_path ) ) {
// set the post meta data -- use relative path
update_post_meta( $post_id, '_wp_page_template', $template_rel_path );
}