Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
266 views
in Q2A Core by

I am using this code and it's working perfect ,,, but I want to display only 200 character of extra field content in homepage ... I have tried this but it doesnt work,,, 

 

$extra = qa_shorten_string_line($extra, 200);
Q2A version: 1.6.3

1 Answer

0 votes
by

It might be this way?

Before:

$extra = qa_db_postmeta_get($post['raw']['postid'], 'qa_q_extra');
if(isset($extra) && $extra != '')
    $this->output('<span class="extra_on_list"> - ('.$extra.')</span>');

After:

$extra = qa_db_postmeta_get($post['raw']['postid'], 'qa_q_extra');
if(isset($extra) && trim($extra) != '')
    $this->output('<span class="extra_on_list"> - ('.qa_shorten_string_line(trim($extra), 200).')</span>');

by
okay sorry ,,, yes its working in function post_meta(...) but I want to use in another function like this;

        function extra_content($post)
        {
  if($post['raw']['type'] == 'Q') {
    require_once QA_INCLUDE_DIR.'qa-db-metas.php';
$extra = qa_db_postmeta_get($post['raw']['postid'], 'qa_q_extra');
if(isset($extra) && trim($extra) != '')
    $this->output('<span class="extra_on_list"> - ('.qa_shorten_string_line(trim($extra), 200).')</span>');
 
  }

and I call this function like this;

        function q_item_main($q_item)
        {
            $this->extra_content($q_item);
        }

but character limit is not working
by
You need to explain in detail the specifications that you want. For example,
"I want to shorten extra field string in ONLY question list." etc.
By the way, you can determine page type in the $this->template.
by
Yes I  want to display extra field content below the question title in question list,,,
by
Sama - where can I find the Extra Field plugin?
...