What are you doing all the time with get_the_excerpt, the_content

Stagger Lee
1833 Posts
Stagger Lee posted this 30 June 2016

It is so, so hard to call it outside the loop. Title, thumbnail, custom fields very easy. But Themler excerpts and content is giving only headache.

It is so, so hard to call it outside the loop. Title, thumbnail, custom fields very easy. But Themler excerpts and content is giving only headache.
Vote to pay developers attention to this features or issue.
11 Comments
Order By: Standard | Newest
Stagger Lee
1833 Posts
Stagger Lee posted this 19 July 2016

@robertmc, sorry I am bussy right now.

@robertmc, sorry I am bussy right now.
robertmc
7 Posts
robertmc posted this 18 July 2016

@Stagger Lee

I apologize for hijacking the thread.

Are you taking on any projects right now?
I need a Themler developer.
Please contact me.

Thank you.

@Stagger Lee I apologize for hijacking the thread. Are you taking on any projects right now? I need a Themler developer. Please contact me. Thank you.
Stagger Lee
1833 Posts
Stagger Lee posted this 18 July 2016

Thank you Support Team, it really works.

Man, yes I know it looks easy now. But I tried hundred of other things by WordPress Codex and from different forums.
Most confusing is my old snippets I have saved stopped to work right, and they worked well before.

Thank you Support Team, it really works. Man, yes I know it looks easy now. But I tried hundred of other things by WordPress Codex and from different forums. Most confusing is my old snippets I have saved stopped to work right, and they worked well before.

Last edited 18 July 2016 by Stagger Lee

Support Team posted this 05 July 2016

Hi.

the_content should be used inside the loop.
This function know nothing about your $cat_post
And code mentioned above doesn't work on default themes too.

If you want to print content outside the loop, use something like this:

apply_filters('the_content', $cat_post->post_content)

Thanks.

Hi. the_content should be used inside the loop. This function know nothing about your $cat_post And code mentioned above doesn't work on default themes too. If you want to print content outside the loop, use something like this: <code> apply_filters('the_content', $cat_post->post_content) </code> Thanks.
Support Team
Support Team posted this 05 July 2016

Hello Stagger Lee,
I'm passing this topic to WP developers for closer analyzes. We'll contact you when they respond.

regards,
Aileen

Hello Stagger Lee, I'm passing this topic to WP developers for closer analyzes. We'll contact you when they respond. regards, Aileen
Stagger Lee
1833 Posts
Stagger Lee posted this 04 July 2016

I would like to make my own call for Themler excerpt / content, outside of Post page, outside of loop. Despite here is code used on Post template it is "outside the loop".

All goes easy but excerpts and contents go through some TH filters and I have problem to display it. It was so from beginning working with TH, just now it is more difficult than ever.

This code above list 4 latest Posts in same Category where I have one Post open (open one is excluded from list)

  • Ttiles belong to right 4 Posts.
  • Thumbnails are right x 4
  • Date is right x 4.
  • User is right x 4

  • Excerpts or content is x 4 but show content of only first Post repeated 4 times. It means code is wrong and some help how to call excerpts / content outside the loop would be nice.

I would like to make my own call for Themler excerpt / content, outside of Post page, outside of loop. Despite here is code used on Post template it is "outside the loop". All goes easy but excerpts and contents go through some TH filters and I have problem to display it. It was so from beginning working with TH, just now it is more difficult than ever. This code above list 4 latest Posts in same Category where I have one Post open (open one is excluded from list) - Ttiles belong to right 4 Posts. - Thumbnails are right x 4 - Date is right x 4. - User is right x 4 - Excerpts or content is x 4 but show content of only first Post repeated 4 times. It means code is wrong and some help how to call excerpts / content outside the loop would be nice.
Support Team
Support Team posted this 04 July 2016

Hello Stagger Lee,
I'm very sorry, I read the entire post but I do not understand what you'd like to do with Themler theme. Could you please provide more detailed description what you'd like to achieve in the theme and what exact difficulties you face at each step.

regards,
Aileen

Hello Stagger Lee, I'm very sorry, I read the entire post but I do not understand what you'd like to do with Themler theme. Could you please provide more detailed description what you'd like to achieve in the theme and what exact difficulties you face at each step. regards, Aileen
Stagger Lee
1833 Posts
Stagger Lee posted this 01 July 2016

You still have problem changing Blog layout and importing Blog style from Clipart change whole Blog layout on Homepage.
I dont think you are aware of this mega problem.

You still have problem changing Blog layout and importing Blog style from Clipart change whole Blog layout on Homepage. I dont think you are aware of this mega problem.
Stagger Lee
1833 Posts
Stagger Lee posted this 01 July 2016

I ended up using one hidden custom template for Related Posts from categories (minus current one). Have this way all TH options for styling and all is working OK.
So not all is negative, losing many hours ended in better idea.

Still would like to know answer to my question, will need it some way or other in the future.

I ended up using one hidden custom template for Related Posts from categories (minus current one). Have this way all TH options for styling and all is working OK. So not all is negative, losing many hours ended in better idea. Still would like to know answer to my question, will need it some way or other in the future.
Stagger Lee
1833 Posts
Stagger Lee posted this 01 July 2016

It can be called when using WP_Query and have_posts. But what when those are not used.
Here is an example. Tell me how would you get excerpts or content here ?
All other works.

<?php
global $post;
$cat_ID=array();
$categories = get_the_category(); //get all categories for this post
  foreach($categories as $category) {
    array_push($cat_ID,$category->cat_ID);
  }
  $args = array(
  'orderby' => 'date',
  'order' => 'DESC',
    'post_type' => 'post',
    'numberposts' => 4,
    'post__not_in' => array($post->ID),
    'category__in' => $cat_ID
  ); // post__not_in will exclude the post we are displaying
    $cat_posts = get_posts($args);
    $out='';
      foreach($cat_posts as $cat_post) {
          $out .= '<li>';
          $out .= get_the_post_thumbnail($cat_post->ID , "thumbnail-featured");
          $out .=  '<h2><a href="'.get_permalink($cat_post->ID).'" title="'.wptexturize($cat_post->post_title).'">'.wptexturize($cat_post->post_title).'</a></h2></li>';
          $out .= the_content();
          $out .= '<p>' . get_the_date() . '</p>';
      }
    $out = '<ul class="cat_post">' . $out . '</ul>';
    echo $out;
?>

It can be called when using WP_Query and have_posts. But what when those are not used. Here is an example. Tell me how would you get excerpts or content here ? All other works. <?php global $post; $cat_ID=array(); $categories = get_the_category(); //get all categories for this post foreach($categories as $category) { array_push($cat_ID,$category->cat_ID); } $args = array( 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'numberposts' => 4, 'post__not_in' => array($post->ID), 'category__in' => $cat_ID ); // post__not_in will exclude the post we are displaying $cat_posts = get_posts($args); $out=''; foreach($cat_posts as $cat_post) { $out .= '<li>'; $out .= get_the_post_thumbnail($cat_post->ID , "thumbnail-featured"); $out .= '<h2><a href="'.get_permalink($cat_post->ID).'" title="'.wptexturize($cat_post->post_title).'">'.wptexturize($cat_post->post_title).'</a></h2></li>'; $out .= the_content(); $out .= '<p>' . get_the_date() . '</p>'; } $out = '<ul class="cat_post">' . $out . '</ul>'; echo $out; ?>
Stagger Lee
1833 Posts
Stagger Lee posted this 01 July 2016

Can we get some help.

What is the right way to get excerpt, or content, outside the loop ?

This is problem I have from Themler beginning. Somehow find a way and you change something in code and doesnt work anymore.
Excerpts and contents in TH go through many filters, changes.

Post title, author, date, post thumbnail, all custom fields. All go directly almost from first try. But excerpts or content, no, no way. It gives only value of first Post for all Posts when called outside the loop.

You did the same with menu Walker. You went an long way away from WP standards. But I dont care about it, as I never have need to call menus manually in templates.

Can we get some help. What is the right way to get excerpt, or content, outside the loop ? This is problem I have from Themler beginning. Somehow find a way and you change something in code and doesnt work anymore. Excerpts and contents in TH go through many filters, changes. Post title, author, date, post thumbnail, all custom fields. All go directly almost from first try. But excerpts or content, no, no way. It gives only value of first Post for all Posts when called outside the loop. You did the same with menu Walker. You went an long way away from WP standards. But I dont care about it, as I never have need to call menus manually in templates.
You must log in or register to leave comments