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

Hi,

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:

<?php

$title=@$this->content['title'];

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
by

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'].'"/>');

by
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 ... "
by
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.
by
I mean the theme's head.php file.
+1 vote
by

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']); ?>"/>

Note:

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

...