Relocating slider to a different page
-
Greetings!
First off – great WP Template. I couldn’t be more pleased with its functionality and flexibility! Seriously, I’m happy to have chosen Graphene as the starting point of my website.
My question, however, is regarding whether or not it is possible to move the slider to a different page (*not* change the position of the slider as it appears on the page). My attempts thus far have been unsuccessful. If it is possible, I’m wondering how you might suggest making this happen.
Currently, when I activate the slider, it appears just below the header on my static front page. I would like the slider to be located just below the header on my blog page – just as it is in the default graphene template.
Because it’s not displaying on the blog page, I’ve deactivated it until I discover a solution. If I can’t find a solution, I’ll have to use a slider plug-in – which I’d rather not do since I rather like the look and feel of the graphene slider.
Any advice or incite would be much appreciated!
Classic Boxing Coach
AdminYou would have to create a child theme to do this. After you have created a child theme, create a new file called
functions.php
. Then insert the following code into that file:<?php
function graphene_display_slider(){
if (is_home())
graphene_slider();
}
?>After that, make sure you activate the child theme through Appearance > Themes.
Thanks for such a quick response!
So, I added the above code to my functions.php file – but it didn’t work. Instead, when I activated the child theme and slider, the site appeared blank (and the wp-admin page was rendered non-functional).
I assumed this was because the blog page is not the ‘home’ page (i.e., my url brings you to the static front page) so I tried changing “is_home” to “is_Blog”. Still, no luck – I got the same results as above.
Any suggestions?
Thanks again Syahir!
Classic Boxing Coach
Ok, I now see there is no such conditional “is_blog” and that “is_home” refers to the index page of my site.
I believe I need to use “is_page” then – but I’m not sure how to identify the page… given that my blog page is titled “Blog”, I expected “if (is_page(Blog))” to work. I got the same result as above.
Hmm…
According to the WP Conditional Codex page, “is_home()” should place the slider on the Page which is set as the “Posts page” in Administration > Settings > Reading. In my case, that’s “Blog”. So I now understand your initial suggestion was correct.
HOWEVER, I discovered this warning: You can only use conditional query tags on or after the init action hook in WordPress. For themes, this means the conditional tag will never work properly if you are using it in the body of functions.php, i.e. outside of a function.
Might this be my issue?
Is there a solution?
AdminThere’s probably an error in the code you just added. Can you paste the entire content of the functions.php file here?
Sure – here you go.
The slider related stuff is last. As you can see, the code you suggest is first and below that is stuff I was experimenting with. All of it is currently commented out.
The remainder of the functions.php file (or at least much of it) has been cut/pasted or adapted from other functions.php files I’ve seen. I admit, I do not completely understand it – but I have managed to make quite a few desired changes.
<?php // custom functions.pihp template @ digwp.com
//
// add feed links to header
//if (function_exists('automatic_feed_links')) {
// automatic_feed_links();
//} else {
// return;
//}
// smart jquery inclusion
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.3.2');
wp_enqueue_script('jquery');
}
// enable threaded comments
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
wp_enqueue_script('comment-reply');
}
}
add_action('get_header', 'enable_threaded_comments');
// remove junk from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
// add google analytics to footer
function add_google_analytics() {
echo '<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>';
echo '<script type="text/javascript">';
echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
echo 'pageTracker._trackPageview();';
echo '</script>';
}
add_action('wp_footer', 'add_google_analytics');
// custom excerpt length
function custom_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'custom_excerpt_length');
// custom excerpt ellipses for 2.9+
function custom_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'custom_excerpt_more');
/* custom excerpt ellipses for 2.8-
function custom_excerpt_more($excerpt) {
return str_replace('[...]', '...', $excerpt);
}
add_filter('wp_trim_excerpt', 'custom_excerpt_more');
*/
// no more jumping for read more link
function no_more_jumping($post) {
return '<a>ID).'" class="read-more">'.'Continue Reading'.'</a>';
}
add_filter('excerpt_more', 'no_more_jumping');
// add a favicon
function blog_favicon() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
}
add_action('wp_head', 'blog_favicon');
// add a favicon for your admin
function admin_favicon() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/images/favicon.png" />';
}
add_action('admin_head', 'admin_favicon');
// custom admin login logo
function custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image: url('.get_bloginfo('template_directory').'/images/custom-login-logo.png) !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
// disable all widget areas
// function disable_all_widgets($sidebars_widgets) {
//if (is_home())
//$sidebars_widgets = array(false);
//return $sidebars_widgets;
//}
//add_filter('sidebars_widgets', 'disable_all_widgets');
// kill the admin nag
if (!current_user_can('edit_users')) {
add_action('init', create_function('$a', "remove_action('init', 'wp_version_check');"), 2);
add_filter('pre_option_update_core', create_function('$a', "return null;"));
}
// category id in body and post class
function category_id_class($classes) {
global $post;
foreach((get_the_category($post->ID)) as $category)
$classes [] = 'cat-' . $category->cat_ID . '-id';
return $classes;
}
add_filter('post_class', 'category_id_class');
add_filter('body_class', 'category_id_class');
// get the first category id
function get_first_category_ID() {
$category = get_the_category();
return $category[0]->cat_ID;
}
/* MOVE THE SLIDER FROM THE HOME PAGE TO THE BLOG PAGE */
/*
function graphene_display_slider(){
if (is_home())
graphene_slider();
}
*/
/*
function graphene_display_slider(){
graphene_slider();
}
add_action('template_redirect','graphene_display_slider');
function blog_slider_mods(){
if (is_home())
graphene_slider();
}
add_action('template_redirect','blog_slider_mods');
*/
?>AdminThere’s something wrong in this part of the code:
function no_more_jumping($post) {
return '<a>ID).'" class="read-more">'.'Continue Reading'.'</a>';
}
add_filter('excerpt_more', 'no_more_jumping');Try commenting that bit out, and then uncomment the codes that I suggested.
Hrm… didn’t work. I commented out the bit you identify above, but when I uncomment the suggested code I get the same result I described above: blank pages.
If you believe there is a problem in my functions.php file, I will experiment with commenting out sections to determine where there may be a conflict. I’ll let you know what I find.
Of course, any additional input is greatly appreciated.
Classic Boxing Coach
When I comment out everything except the suggested code, I get blank pages. I’m perplexed.
Viewing 10 posts - 1 through 10 (of 16 total)
- 1
- 2
- You must be logged in to reply to this topic.