• Resolved khlota

    (@khlota)


    I understand that there is a main template and a template for single pages. M site uses the index.php and page.php for the pages I have set up. I also understand that dynamic numbers are assigned to these pages to help identify them. What I want is to customize (if nothing else just by changing the image) to all 4 of my pages.

    I have created a additional sidebar2.php and was about to add that to the page.php but I don’t see how to access or customize my CSS to my other pages (id’s are 2, 8 and 11).

Viewing 9 replies - 1 through 9 (of 9 total)
  • all pages regardless of ID use the page.php

    Thread Starter khlota

    (@khlota)

    Based on what I think this means I can take Snippet 3 and add it to my functions.php BUT I have some additional questions/concerns.

    1) My functions.php references 2 other files in a function directory – sandbox.php and modmat.php. It would seem based on the code that sandbox.php is where I should add this. CORRECT? And does it replace something or is it addition to? Line 103 seems to have similar info.

    2) This code also references images which I don’t nee. I hope to be able to just replace the () with the name of the link and the ID with the number.

    Can I adjust the code like this? And remove the 2nd and 3rd lines?
    if ( is_page('advertising') || $post->post_parent == '11' ) {

    This is the original Snippet 3.

    <?php
    
    if ( is_page('about') || $post->post_parent == '2' ) {
        // the page is "About", or the parent of the page is "About"
        $bannerimg = 'about.jpg';
    
    } elseif ( is_page('learning') || $post->post_parent == '56' ) {
        $bannerimg = 'teaching.jpg';
    
    } elseif ( is_page('admissions') || $post->post_parent == '15' ) {
        $bannerimg = 'admissions.jpg';
    
    } else {
        $bannerimg = 'home.jpg'; // just in case we are at an unclassified page, perhaps the home page
    }	
    
    ?>

    ANY ADVICE IS GREATLY APPRECIATED.

    Thread Starter khlota

    (@khlota)

    SCRATCH WHAT I WROTE ABOVE, didn’t work anyway and not sure if it did it would accomplish all that I need ??

    I found this from another post and adjusted it. What I am trying to accomplish is that a specific page (ID) calls a specific sidebar. This did not work but I feel like with a little love it could ?? WHO HAS SOME LOVE FOR ME?!

    if (is_page('about') || $post->post_parent == '2' ) {
    		include(TEMPLATEPATH . '/sidebar2.php');
    	} else {
    		include(TEMPLATEPATH . '/sidebar.php'); }
    
    if (is_page('gallery') || $post->post_parent == '8' ) {
    		include(TEMPLATEPATH . '/sidebar2.php');
    	} else {
    		include(TEMPLATEPATH . '/sidebar.php'); }
    
    if (is_page('advertising') || $post->post_parent == '11' ) {
    		include(TEMPLATEPATH . '/sidebar2.php');
    	} else {
    		include(TEMPLATEPATH . '/sidebar.php'); }

    Too many else statements.

    Try:

    $parents = array('2','8','11');
    if( is_page(array('about','advertising','gallery')) || in_array($post->post_parent,$parents) ) include(TEMPLATEPATH . '/sidebar2.php');
    else include(TEMPLATEPATH . '/sidebar.php');

    I haven’t tested this so I’m not 100% sure about the post parents bit.

    Thread Starter khlota

    (@khlota)

    OMG. That isn’t it! I get mixed reactions on this. Not sure if you are up still…. if so, here it is.

    https://myownway.com/blog/?page_id=2

    If not I will try to explain in case I have moved on before you see this. Sidebar.php forced into a 0,0 position on all pages. Sidebar2.php is also present in addition to Sidebar.php in the correct positions on Gallery and Advertising pages.

    I will try to work with this of course until I hear from you again!

    Thread Starter khlota

    (@khlota)

    What is also interesting and bizzare is that Sidebar.php is also now showing up with different content.

    My secondary sidebar in sidebar.php has ‘search’, ‘rss feeds’ and ‘meta’, while my secondary sidebar in sidebar2.php has ‘recent posts’, ‘archives’ and ‘tag cloud’. WEIRD. What is in Sidebar2 is correct, although I did try to add the Meta Widget in multiple times and it just wouldn’t save the settings.

    Thread Starter khlota

    (@khlota)

    You know what both primary and secondary sidebars differ in each php. That is unexplainable to me.

    Thread Starter khlota

    (@khlota)

    EVERYTHING WORKS NOW IN REGARDS TO THIS POST. I DID NOT HAVE TEMPLATES PAGES CREATED. THANK YOU.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to Access Dynamic Page Id’s’ is closed to new replies.