ThemeShaper Forums » Thematic

Multiple page exerpts ?

(11 posts)
  • Started 11 years ago by deepshade
  • Latest reply from deepshade
  • This topic is not resolved
  1. deepshade
    Member

    New to WP and thematic.
    Could be a WP question
    Problem with Excerpt

    I want to use the custom field in the home page to tell my home page which story to use for precis of a 'company info'
    ie about page ID = 32
    custom field = info_page
    value = 32
    And that part is working

    // extract the  info page id from the home page custom field info_page
    $featured_info_page_id = get_post_meta($post->ID,'info_page',true);
    $featured_info_page_data = get_page( $featured_info_page_id );

    ALL OK SO FAR

    echo $title = $featured_info_page_data->post_title; // CORRECTLY ECHOS THE CHOSEN PAGES TITLE
    echo $post = $featured_info_page_data->post_content;// THIS ALSO WORKS BUT I ONLY WANT AN EXCERPT
    echo $post = $featured_info_page_data->post_date.'';
    echo $post = $featured_info_page_data->post_excerpt.'';//THIS PARAM IS IN THE CODEX BUT DOESNT WORK
    echo the_excerpt().'';//THIS ECHOS THE DEFAULT HOME PAGE ARTICLE AS AN EXCERPT

    help appreciated

    Posted 11 years ago #
  2. Hi deepshade-

    New to WordPress and in deep, I can appreciate that. I'll try and explain some about using excerpts in this manner with get_post() or get_page().

    There are two types of excerpts that are automated (drawn from `get_the_content() and filtered by other php functions) or ones that are custom (wp-admin write panel user input).

    At the database level WordPress allows for custom excerpts and custom content for pages and posts, Although it has custom excerpts disabled from the page write panel by default so this value tends to be empty.

    The functions get_post() and get_page() are pulling records from the database. If you are trying to receive an auto-generated excerpt from either post or page you need to get not echo the post_content and filter out auto-excerpt to your liking and then echo that.

    If you want to use the custom excerpt with posts you're all set out of the box but not with pages. For pages you need to turn on this functionality from within your child-theme's functions.php and then enter a custom excerpt for pages via the wp-admin write panel.

    Here is an excellent cut and paste tutorial for doing just this:

    http://mfields.org/blog/2008/04/02/how-to-activate-excerpts-for-pages-in-wordpress-admin-panel/

    Hope this helps some.

    -Gene

    Posted 11 years ago #
  3. deepshade
    Member

    Hi Gene

    Your feedback is very much appreciated. It's going to take a while to become familiar with the general syntax and functions. And when your just starting their seems to be a huge pile!. Clearing a small path like this really helps!

    I like the idea of being able to add a custom Excerpt in Admin - and thanks for the reference link. I'm sure thats going to be very useful later on.For now I'd like to create an automatic excerpt from a specified page on the home page (identified by a custom field on the home page). To clarify in my head what's going on more than anything.

    I'm using exerpt already on another part of my home page and thats working fine (Featured theme feature-front-1php) automatically picking up articles from another page - again using a custom list of IDs. So it is doubly puzzling.

    This section below is on another include (Featured theme front-page.php) - again rather than manually enter some text I wanted to pick it up from a specified page.

    WP is confusing here (or I've gotten the wrong end of the stick - which is more likely) no params on excerpt()!
    Everything is working - I can get the correct page - just can't seem to pass it to exerpt

    I get the $pageID I'm interested in (from whatever source -here its a custom field)
    I $pageDATA=get_page($pageID) the page data into a variable
    filter out auto-excerpt?????
    echo excerpt() - as this function has no params - I assume its pointing at the variable $pageDATA ?
    the full page data echos correctly
    but the excerpt echos my home page - page?

    frustrating - but I'm sure the clouds will soon clear!

    tia

    Paul/Deepshade

    Notes:
    Using RC 3.0
    The only difference I can see is ....

    front-page-1.php is pulled in by the child themes functions page thematicfeaturesite/functions.php

    and front-page is pulled in by wp-includes/theme.php and the above functions page

    Posted 11 years ago #
  4. deepshade
    Member

    I've tried everything and can't find a solution - any WP guru's out there?

    Help would be much appreciated

    Posted 11 years ago #
  5. deepshade
    Member

    I think I understand the problem a little better - but still need some direction.

    Loading a featured front page article (that is different from the home page default article) thematicfeaturesite - mod
    I can get a list of IDs (from a custom field on the home page)
    I can output that pages title and content and date and....
    echo $page_data->post_whatever...

    I can also add support for a manually added excerpt

    BUT
    I cant seen to use the built in the_excerpt() function to display one of these posts, because it always defaults to the home page content and there's no way to pass a page ID to the_excerpt()

    If I use the_content() and inset a MORE tag in the article - nothing happens

    I don't want to write manual experts

    rather stuck - any help appreciated

    Posted 11 years ago #
  6. Hi Paul,

    Sorry to have let this hang. I got swept up in something. Here is an example of using a custom query to do this more simply:

    function insert_my_page_excerpt() {
    	if ( is_front_page() )  {
    		query_posts('page_id=32');
    		the_post();		// sets up the post data
    		the_excerpt();	// echoes the excerpt
    		wp_reset_query();	// resets the query
      }
    }
    add_action('thematic_abovecontainer','insert_my_page_excerpt');

    See if you can put this to better use than my ramblings on get_page You may want to adjust the conditional, the action hook, and add markup to flesh this out.

    Ref: http://codex.wordpress.org/Function_Reference/query_posts

    -Gene

    Posted 11 years ago #
  7. deepshade
    Member

    Thanks Gene

    will take a look

    ahhhhh - driving me mad - thinks its just down to me stuck on syntax..

    I have my own variable
    $page_id = the page I'm interested in
    $page_id=47
    check with echo
    47 - so I know I've got the page lined up for output

    running
    query_posts('page_id=47');
    works :)

    BUT
    query_posts('page_id='.$page_id);

    doesnt??????

    trying various options - no luck so far

    I'm confused!

    take it out of the function and insert it into the page manually and it works?

    $posts=query_posts('page_id='.$page_id);
    the_post(); // sets up the post data
    the_excerpt(); // echoes the excerpt
    wp_reset_query(); // resets the query

    Posted 11 years ago #
  8. Try storing the arguments in a variable and then passing that variable into the function

    $id = 21;
    $arg = 'page_id='.$id;
    query_posts($arg);
    Posted 11 years ago #
  9. deepshade
    Member

    $arg = 'page_id='.$page_id;
    query_posts($arg);
    
    function insert_my_page_excerpt($arg) {
    
    	if ( is_front_page() )  {
    		$posts=query_posts($arg);
    		the_post();		// sets up the post data
    		the_excerpt();	// echoes the excerpt
    		wp_reset_query();	// resets the query
      }
    }

    Now dumps the whole post

    I'm wondering if its down to me using/modding the featured theme page?

    At least I'm moving forward and learning - thanks for the nudges Gene
    Need to read some more ...query_post...what I needed!

    Posted 11 years ago #
  10. I'm sorry I didn't explain that well. The function i meant you to pass $args to was query_posts()

    Try something more like this keeping the variables inside insert_my_page_excerpt() and only passing $arg to query_posts()

    function insert_my_page_excerpt() {
    $id = 32;
    $arg = 'page_id='.$id;
    	if ( is_front_page() )  {
    		query_posts($arg);
    		the_post();		// sets up the post data
    		the_excerpt();	// echoes the excerpt
    		wp_reset_query();	// resets the query
      }
    }
    add_action('thematic_abovecontainer','insert_my_page_excerpt');
    Posted 11 years ago #
  11. deepshade
    Member

    will give it a go - thanks again
    this mist is clearing

    Posted 11 years ago #

RSS feed for this topic

Reply

You must log in to post.