Jump to content
Sign in to follow this  

Custom Section Post Feed Stopped Working

Recommended Posts


I created a custom section that pulls post content and displays it on a static home page for a client. The section works perfectly on my draft site at http://quantumpolitics.org/kwame5/ but it won't show up on the new site at http://www.dccouncilchair.com/. I currently have the dccouncilchair.com site under lock down because it's in final stages of being transferred. This is the only thing holding me back from going public. The section I'm referring to is the "Latest News" section. Here's the section code I'm using...maybe someone can help decipher the problem:

		Section: Post Feed Section
		Author: Quantum Politics, LLC
		Description: Replaces the content section of the static home page, to include a post feed instead of the page content.
		Version: 0.0.1
		Resources: template.content.php, section.pullquote.php
	class BasePostFeed extends PageLinesSection {
	   function __construct( $registered_settings = array() ) {
				/* The name and ID of the section */
				$name = __('Content Area: Post Feed', 'pagelines');
				$id = 'post_feed';
				// Setup description of the section..
				$default_settings['description'] = 'Replaces the content area of the static home page to include a post feed instead of the page custom page content. .';
				// The template areas this section works with..
				// Examples areas: 'main', 'content', 'header', 'footer', 'morefoot', sidebar1, array('main', 'content'), etc....
				$default_settings['workswith'] = array('static_home');
				// The icon users will see in the admin.. add the full url here
				$default_settings['icon'] = PL_ADMIN_ICONS . '/feed.png';
			// OPS
				/* Draw section using the section API - don't need to touch this*/
				$settings = wp_parse_args( $registered_settings, $default_settings );
			   	parent::__construct($name, $id, $settings);
		/* Use this function to create the template for the section */
	 	function section_template() {
			// Draw the HTML ?>
			<?php global $pagelines_layout;?>
<?php pagelines_register_hook( 'pagelines_content_before_columns', 'maincontent' ); // Hook ?>
<?php pagelines_register_hook( 'pagelines_content_before_maincolumn', 'maincontent' ); // Hook ?>

Latest News

<?php global $post; $args = array( 'numberposts' => 1, 'order'=> 'ASC', 'orderby' => 'date', 'category' => 51 ); $myposts = get_posts( $args ); foreach ($myposts as $post) : setup_postdata($post); ?>

<?php the_title(); ?>

<?php the_date(); ?>
<?php the_excerpt(); ?>
Read more...?†’ <?php endforeach; ?>
<?php if($pagelines_layout->layout_mode == 'two-sidebar-center'):?> <?php pagelines_register_hook( 'pagelines_content_before_sidebar1', 'maincontent' ); // Hook ?>
<?php pagelines_template_area('pagelines_sidebar1', 'sidebar1'); ?>
<?php pagelines_register_hook( 'pagelines_content_after_sidebar1', 'maincontent' ); // Hook ?> <?php endif;?>
<?php get_sidebar(); ?>
<?php } // Some of the optional functions not used here. function section_options($optionset = null, $location = null) {} /* Adds Options in the admin. Use this function to add them; see PageLines.com for more info */ function section_persistent(){} /* Runs in every page, including in admin (not used in this section) */ function section_head(){} /* Runs in site header, only if section is active (not used here) */ } /* End of section class - No closing tag needed */ [/code]

Share this post

Link to post
Share on other sites
I'll bump this up to a developer.

Former PageLines Moderator, Food Expert and Raconteur

Share this post

Link to post
Share on other sites
I figured it out. It was simple. When I was doing the transfer, the category number changed to 25. Now it's posting correctly. Hope someone else can use the code for their site. Enjoy.

Share this post

Link to post
Share on other sites
Did you remember to register the section if functions.php? Is it just not working on the page or is it not showing up the the sections area at all? Also this line: [code] $default_settings['workswith'] = array('static_home'); [/code] try changing to this: [code] $default_settings['workswith'] = array('static_home','templates'); [/code] or [code] $default_settings['workswith'] = array('static_home','template'); [/code] I can't remember which atm.

Share this post

Link to post
Share on other sites
The section is registered. The problem was that the category # was wrong. It was reading the php properly but it was pulling content from a category that didn't exist. Once I changed the category # below it worked great again. The number changed during the transfer from one site to the next: [code]$args = array( 'numberposts' => 1, 'order'=> 'ASC', 'orderby' => 'date', 'category' => 51] );[/code] At some point I'll have to learn how to generate it dynamically so it won't be a problem in future cases. For anyone looking to use the section in their sites, here are the arguments get_posts will take: http://codex.wordpress.org/Template_Tags/get_posts. Thanks for your quick response. I'll post the final site in the showcase.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this