Forum

 
You must be logged in to post Login Register


Register? | Lost Your Password?

Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

Want gallery to display the post's excerpt

closed
UserPost

7:09 pm
December 22, 2008


cdatwood

New Member

posts 2

1

Hello all,

I have been trying to make the DCG display the post's excerpt if no description is available in the meta data.

The original code for where it display's text is in:

         <h3><?php the_title(); ?></h3>
                                        
        <?php if( get_post_meta($post->ID, "dfcg-desc", true) ): ?>
            <p><?php echo get_post_meta($post->ID, "dfcg-desc", true); ?></p>
        <?php elseif (empty($dfcg_category->category_description)): ?>
            <p><?php echo $dfcg_imgdefdesc; ?></p>
        <?php else: ?>
            <p><?php echo $dfcg_category->category_description; ?></p>
        <?php endif; ?>

My modified code is:

         <h3><?php the_title(); ?></h3>

                                        

<?php if( get_post_meta($post->ID, "dfcg-desc", true) ): ?>
   <p><?php echo get_post_meta($post->ID, "dfcg-desc", true); ?></p>
  <?php elseif (empty($dfcg_category->category_description)): ?>
   <p><?php echo $dfcg_imgdefdesc; ?></p>
  <?php else: ?>
   <p><?php echo $dfcg_category->category_description; ?></p>
   <p><?php the_excerpt(); ?></p>
  <?php endif; ?>

I have also tried cutting the elseif (empty($dfcg_category->category_description)): ?> statement from the deal, but I cannot make it show the excerpt.

The function the_excerpt() returns a set excerpt, or a 120 character block of the post while "in the loop". My demo is http://www.atwookie.com, and it is using the default images, but I want it to display the post's excerpt instead of a category description, as well, because the excerpt can be automatically generated.

If anybody has any thoughts, please help!!!

Thanks,
Chris

8:07 pm
December 22, 2008


Ade

Admin

posts 1140

2

Chris,

Try replacing this bit of code from the example you posted:

<?php else: ?>
   <p><?php echo $dfcg_category->category_description; ?></p>
   <p><?php the_excerpt(); ?></p>
  <?php endif; ?>

with this:

<?php else: ?>
   <p><?php the_excerpt(); ?></p>
  <?php endif; ?>

But this will only work if no custom field dfcg-desc has been set up.

Dynamic Content Gallery: Have you read the Configuration Guide and FAQ?

8:13 pm
December 22, 2008


cdatwood

New Member

posts 2

3

I think the problem lies with "the_excerpt()", as if I move out of the conditional structure, and tell it to echo text, the text appears. If I put <p><?php the_excerpt(); ?> </p>, then it outputs nothing. I wonder if the block of text is too large for the bar so none of it displays? Possible?

9:24 pm
December 22, 2008


Ade

Admin

posts 1140

4

Try replacing this:

<p><?php the_excerpt(); ?></p>

with this:

<p><?php echo $post->post_excerpt; ?></p>

Ade.

Dynamic Content Gallery: Have you read the Configuration Guide and FAQ?

3:04 am
February 14, 2010


vaha

New Member

posts 1

5

Can you please tell me in what file did you change that code?

I have 3.2.2 version and i would like to use content from Excerpt field?

7:15 pm
February 14, 2010


Ade

Admin

posts 1140

6

It would be in the gallery constructor files (/includes/dfcg-gallery-constructors.php and /includes/dfcg-gallery-constructors-js.php).

You're on your own on this. Wink

I've added this to the to-do list for the next version.

Dynamic Content Gallery: Have you read the Configuration Guide and FAQ?