Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

[SOLVED] Mixing static content + excerpts on home and category pages ?


  #1  
Old May 13, 2011, 06:12 AM
jmc34
 
19 posts · Oct 2010
Hi there,
I am working on the web site of my bike club and would like to be able to mix static HTML content and excerpts on both the home page and *some* category pages.

I am new to all this WP thing, and I must say that I do not know where to start.

I was thinking that I would put my static HTML content into files that I can then include, but that is the only hint I do have.

Here might not be the right place to ask this question (as I am not sure if it is a theme question or a WP question), so feel free to point me in the right direction.

Any pointers will be much appreciated.

Subsequently I might want to display exerpts on the home in two columns (I saw a sticky about that) en have different number of excerpts for some categories, but we will cross that bridge when we will cross that bridge.

Thanks in advance for your help.

Jean-Michel.
  #2  
Old May 13, 2011, 09:48 AM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
There is a custom query page template in the Gold forum that may do what you want. I typically use the List Category Posts plugin for that type of functionality.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #3  
Old May 13, 2011, 10:00 AM
jmc34
 
19 posts · Oct 2010
Hi Miles,
not sure what the gold forum is (did not find it) but at the fisrt glance it would seem that this plugin will do the trick.

Hopefully it is not too heavy as my ISP only allows 32M for PHP, that does not allow for much plugin fantasy at all (especially on a 64bits server)...

I'll give it a go.

Thanks again,
JM
  #4  
Old May 13, 2011, 10:43 AM
jmc34
 
19 posts · Oct 2010
Hmmm...

This plugin is a start, but not really what I was looking for...

Have a look : http://jeanmichel.cazaux.free.fr/sit...ex.php/courses

I am trying to have the static content displayed in its own "box" and then the posts formated as "normal" excerpts...

Almost like if the static content was the first post of the page displayed "in full" and then the exerpts (somle of them)...

Any other hint?
I am happy (and probably can) do a bit of basic PHP tweaking if I have to.

Thanks
JM
  #5  
Old May 13, 2011, 10:55 AM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
What did you use for the plugins shortcode. You should be able to use something like the following to give you a list if excerpts from 10 posts in a category or categories In this case categories 12 and 13.
There is a list of all the attributes for this plugin on the Other Notes tab.

[catlist id=12,13 excerpt=yes numberposts=10]
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #6  
Old May 13, 2011, 11:36 PM
jmc34
 
19 posts · Oct 2010
I did use those keywords (exactly [catlist name=courses excerpt=yes comment=yes thumbnail=yes]), and it does show the right things, but not really in the format I am expecting...

I think I might throw myself in modifying the index.php just a bit...

Sounds like a good challenge but makes each upgrade then more difficult (this stated I am stuck with 3.5.3 due to the Suhosin issue...

I you have other ideas, please fire!

Thanks, JM
  #7  
Old May 14, 2011, 08:06 AM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
How do you want them to show?
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #8  
Old May 15, 2011, 01:44 AM
jmc34
 
19 posts · Oct 2010
I'd like my page to show excerpts formatted "by default" plus some static content (possibly coming from a file, but that is an option).

The static content would only show on excerpts pages, post pages would show "as normal" posts.

A bit like this:


What i was thinking (to make it a bit generic) is to have my static content in a file named according to a defined schema (for example static_insert_cat_[ID].html, where [ID] would be the category ID) and in index.html I can test if this file exists and include it if it does.

This assumes that:
- I can and know how to test what category I am displaying;
- I can and know how to test if I am on an excerpts page or a normal page...

But I would be surprised if I cannot do that.

Thanks,
JM
  #9  
Old May 15, 2011, 10:13 PM
aQuickStudy's Avatar
aQuickStudy
 
43 posts · Mar 2010
Couldn't you add a widget area to the top of the center column and use a widget for your static content?
  #10  
Old May 16, 2011, 01:51 AM
jmc34
 
19 posts · Oct 2010
I did not know you could put a widget on the center column...

Is this possible?

JM
  #11  
Old May 16, 2011, 02:14 AM
jmc34
 
19 posts · Oct 2010
Ok, after a bit of tinkering with index.php, I eventually got where I wanted to be...

In the current guise, my solution includes the content of a file named static_heading_cat_slug.html or static_heading_cat_id.html before the posts of category slug (or with ID id) on an excerpts page.

The content of the file will be displayed above the posts and after the navigation section.

If some static content is found, the number of excerpts is limited to 3 (I did not find a way to make this variable).

I could have stopped there but decided to add a bit of icing on the cake...

If there are no posts to display, I try to include a file named:
-static_empty_cat_slug.html
-static_empty_cat_id.html
-static_heading_cat_slug.html
-static_heading_cat_id.html

The first file matching one of these names is included. This allows for having a longuer/different static content when there are no posts.

As well, the 'no_content_found' content is not displayed if some static content is found.

That is a bit complex maybe, but while at it, I thought I would cover the last mile.

I modified the wordpress/theme/atahualpaXXX/index.php file as follows:

Between
Code:
	<?php /* This outputs the next/previous post or page navigation. 
	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
	bfa_center_content($bfa_ata['content_above_loop']); ?>
and
Code:
	<?php /* The LOOP starts here. Do this for all posts: */
	while (have_posts()) : the_post(); $bfa_ata['postcount']++; ?>
(around line 13), add the following :
Code:
	<?php /* STATIC_CONTENT_ON_CATEGORIES */
	$included_static_content = false;
	if (is_category() && !is_single()) {
		// we are on a category page and not on a single post page
		// We get the category (not as simple as get_the_category() that gives erroneaou results
		global $wp_query;
		$cat_ID = get_query_var('cat');
		$category = get_category($cat_ID,false);
		/* Do we have a static content file for this category ?
		We build an array with possible filenames (in order of precedence)... */				
		$upload_dir = wp_upload_dir();
		$filenames = array();
		$filenames[0] = $upload_dir[basedir]."/static_heading_cat_".$category->slug.".html";
		$filenames[1] = $upload_dir[basedir]."/static_heading_cat_".$category->term_id.".html";
		
		/* We try each file(name) in the array */
		foreach ($filenames as $i => $filename) {
			if (file_exists($filename)) {
				include($filename);
				$included_static_content = true;
				break;
			}
		}		
	}
	?>
This will include the static files above the posts when there are posts.

After
Code:
		<?php /* This is the actual Wordpress LOOP. 
		The output can be edited at Atahualpa Theme Options -> Style & edit the Center column */
		bfa_center_content($bfa_ata['content_inside_loop']); ?>
add:
Code:
		<?php
		/* STATIC_CONTENT_ON_CATEGORIES */
		if ($included_static_content && $bfa_ata['postcount']==3) {
			// We need to limit the number of excerpts
			break;
		}
		?>
This will stop the loop after the 3rd post if we have included static content.

Then we will take care of the case when there were no posts...

Towards the end of the file REPLACE :
Code:
<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.
This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
bfa_center_content($bfa_ata['content_not_found']); ?>
with:

Code:
<?php /* END of: If there are any posts */
else : /* If there are no posts: */
	/* STATIC_CONTENT_ON_CATEGORIES */
	$included_static_content = false;
	if (is_category()) {
		// we are on a category page and not on a single post page
		// We get the category (not as simple as get_the_category() that gives erroneaou results
		global $wp_query;
		$cat_ID = get_query_var('cat');
		$category = get_category($cat_ID,false);
		/* Do we have a static content file for this category ?
		We build an array with possible filenames (in order of precedence)... */				
		$upload_dir = wp_upload_dir();
		$filenames = array();
		
		$filenames[0] = $upload_dir[basedir]."/static_empty_cat_".$category->slug.".html";
		$filenames[1] = $upload_dir[basedir]."/static_empty_cat_".$category->term_id.".html";
		$filenames[2] = $upload_dir[basedir]."/static_heading_cat_".$category->slug.".html";
		$filenames[3] = $upload_dir[basedir]."/static_heading_cat_".$category->term_id.".html";
		
		/* We try each file(name) in the array */
		foreach ($filenames as $i => $filename) {
			if (file_exists($filename)) {
				include($filename);
				$included_static_content = true;
				break;
			}
		}		
	}

	/* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.
	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
	/* STATIC_CONTENT_ON_CATEGORIES 
		We only included 'content_not_found' if no static content has been found */
	if (!$included_static_content)
		bfa_center_content($bfa_ata['content_not_found']); ?>
This will look for the various files we can include there and will NOT display $bfa_ata['content_not_found'] is one of the files was found.

Ah, last detail, this assumes the files are in the wordpress/uploads directory.

I hope this will be useful to someone, please feel free to use and reuse.

Jean-Michel
  #12  
Old May 16, 2011, 02:18 AM
jmc34
 
19 posts · Oct 2010
And you can even find the edited index.php (as index_php.txt) here.

Enjoy,
Jean-Michel

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] 2 Home Pages w-Static Front Page, How to Have Only One? Simeon Page & Category Menu Bars 3 Nov 19, 2010 10:09 PM
Adding Static Content "Above the Loop" on home page dchrist21 Center area post/pages 2 Sep 30, 2010 02:31 PM
[SOLVED] category menu bar shows up on static home page, although I'd deleted it. mathmojo Page & Category Menu Bars 1 Jun 27, 2010 06:28 PM
Static Home Page - Pages - Articles - Posts ScottiedogDave Atahualpa 3 Wordpress theme 3 Apr 17, 2009 06:10 AM
[SOLVED] How to show single post special category on static home page?? Shepherd Jim Post-Kicker, -Byline & -Footer 5 Mar 19, 2009 07:42 AM


All times are GMT -6. The time now is 05:06 PM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.