Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
837 views
in Q2A Core by
edited by
Hello, I would like to know how to include the meta description of a category .
In the code shows only the title.
 

Example:

  <title>xxxxxxx</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="canonical" href="http://www.xxxxx.com/art">
 
 
Q2A version: 1.7.1

1 Answer

0 votes
by
edited by

In your theme file qa-theme.php check if there is a function head_metas() if there is than add only below line in that

$this->output('add your meta tag here');

Otherwise add this entire function

function head_metas()
{
    qa_html_theme_base::head_metas();
    $this->output('add your meta tag here');
}

This is only for meta tags and other tags you should add to appropriate class method.


Updated Code

Multiple Meta tags

function head_metas()
{
    qa_html_theme_base::head_metas();
    $this->output('<meta ..... >');
    $this->output('<meta ..... >');
    $this->output('<meta ..... >');
}

You also can use comma in one output but to keep it easy just add new output for each meta as above.

Why you need title tag? It will be generated automatically.. You do not need to add it.

by
I have checked and tried , the result is that I now have two descriptions in the questiones and only one in the categories.

so it goes into categories :
<title>xxxxxxx</title>
        <meta name="description" content="bla bla bla bla">
        <meta name="keywords" content="art">

so it goes into questions :
<title>xxxxxxx</title>
        <meta name="description" content="bla bla bla bla">
        <meta name="keywords" content="art">
        <meta name="description" content="">


thanks for comment.
by
See my updated code
by
edited by
I am copying the visible result m that faces the search code .

 I just want the categories have a description , if it comes to questions .

I saw the file default.php file is where the title to the different categories are included.

In this file I see that references the categories meta description .

if ($countslugs) {
        if (!isset($categoryid))
            return include QA_INCLUDE_DIR.'qa-page-not-found.php';

        $categorytitlehtml=qa_html($categories[$categoryid]['title']);
                
        $sometitle=qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
        $nonetitle=qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
                



    }
by
Finally I solved .
You just have to add :
 
else {
$qa_content['description']=qa_html($categories[$categoryid]['content']);
}

in default.php
...