• On the following site, I want to load the Events Calendar page content to the right sidebar instead of the current “About” content.

    http://ghanasurfingassociation.com/

    I found ways to have the title of the page, links to the page, etc. – but didn’t find anything yet that would load the page title and the page content.

    TIA,
    greg

Viewing 5 replies - 1 through 5 (of 5 total)
  • You could put the following code into your sidebar.php template file. This will create a custom loop that will allow you to display the content of your Events Calendar page in the sidebar. Any widgets you might have will appear underneath.

    <div id="primary-sidebar">
    <?php
    $args=array(
        'post_type'=>'page',
        'post__in' => array('11') // ID of your Events Calendar page goes here
    );
    $events_calendar = new WP_Query($args);
    while ($events_calender->have_posts()) : $events_calendar->the_post();
        the_title();
        the_content();
    endwhile;
    
    if ( !function_exists('dynamic_sidebar')  || !dynamic_sidebar('Sidebar') ) :
    endif;
    ?>
    </div>
    Thread Starter briz_dad

    (@briz_dad)

    I received the following error:

    Parse error: syntax error, unexpected ‘}’ in /home/content/b/l/a/blackstarsurf/html/gsa/wp-content/themes/gsa/sidebar/sidebar-default.php on line 44

    Here is the code I have pasted on the page:

    <?php
    
    // This file is part of the Carrington Text Theme for WordPress
    // http://carringtontheme.com
    //
    // Copyright (c) 2008-2009 Crowd Favorite, Ltd. All rights reserved.
    // http://crowdfavorite.com
    //
    // Released under the GPL license
    // http://www.opensource.org/licenses/gpl-license.php
    //
    // **********************************************************************
    // This program is distributed in the hope that it will be useful, but
    // WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    // **********************************************************************
    
    if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
    if (CFCT_DEBUG) { cfct_banner(__FILE__); }
    
    ?>
    
    <div id="sidebar">
    
    <div id="primary-sidebar">
    <?php
    $args=array(
        'post_type'=>'page',
        'post__in' => array('12') // ID of your Events Calendar page goes here
    );
    $events_calendar = new WP_Query($args);
    while ($events_calender->have_posts()) : $events_calendar->the_post();
        the_title();
        the_content();
    endwhile;
    
    if ( !function_exists('dynamic_sidebar')  || !dynamic_sidebar('Sidebar') ) :
    endif;
    ?>
    </div>
    
    </div><!--#sidebar-->

    (It is not live since it breaks the page)

    Can you see what is incorrect?

    Thread Starter briz_dad

    (@briz_dad)

    I’m sorry – the error with the code I placed in the above response is:

    Fatal error: Call to a member function have_posts() on a non-object in /home/content/b/l/a/blackstarsurf/html/gsa/wp-content/themes/gsa/sidebar/sidebar-default.php on line 32

    line 32 is:
    while ($events_calender->have_posts()) : $events_calendar->the_post();

    Yes, I made a small typo, sorry (misspelled ‘calendar’ as ‘calender’). That line should read:

    while ($events_calendar->have_posts()) : $events_calendar->the_post();

    Thread Starter briz_dad

    (@briz_dad)

    that works!!! thank you so much for your time and help…

    I looked at that misspelling several times and didn’t see/catch it.

    Sincerely,
    Greg

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘page content to sidebar?’ is closed to new replies.