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


I'm new with q2a and I have some issues.

I want to add  a <meta> tag in my head section, and I can't echo the name/ title of the curent page.

<meta name="og:title" content=" *title of the question page* "/>

I tried something  like this:



echo $title;


but it's not working.

So, how do I get to display the Title, Tags and Categories ?

Q2A version: 1.6.2

2 Answers

0 votes

You didn't say exactly where you put that code but I assume you're using an advanced theme. In which case you should use:

$this->output('<meta name="og:title" content="'.@$this->content['title'].'"/>');

you assume correctly, I'm using an advanced theme. I want to place the meta tags in the head file.
I tried your code and  i get this error:" Fatal error: Using $this when not in object context ... "
What do you mean by "head file"? Do you mean "head function"?

The variable $this->content['title'] should be available at any point in the theme.
I mean the theme's head.php file.
+1 vote

if you are using Dude theme, follow this:

open head.php and add below code inside <head> tag:

<meta name="og:title" content="<?php echo strip_tags(@$context->content['title']); ?>"/>


$this->content['title'] has html tags so dont dirctly use this in head, remember to use strip_tags();