dynamic meta data and description for pages - php

I am developing pages in php dynamically i.e data gets filled up from mysql DB. how do i assign a proper meta data and description for these dynamic pages so that google recognises it properly.
What needs to be passed in page so that google takes description properly. when i search a page in google. it takes the data in page as description not description tag contents

<meta name="description" content="<?php echo $your_meta_description ?>" />

It depends on what you are using to build your site. Wordpress, for instance, doesn't come with meta description functionality by default. You would need to use a plugin.
Google will use your description only if it contains the keyword been searched for, and if it confirms that the meta description supplied accurately describes the content of the page.
This article might help: How to specify how your site looks in the search engines

Related

Dynamic search in WordPress

I'm working on a WordPress site for a client, and I need a custom search box in the header. The site is using their external e-commerce tool from CNET. So the e-commerce pages in their WordPress site consist of an iframe displaying a URL to their CNET store.
So on the store search page, the iFrame URL looks like:
https://store.com/ourstore/Search/Category/?search_string=
Obviously, here you can pass in your search term into the URL string. So if I wanted to search for Dell Laptops, the URL to use in the iFrame would be:
https://store.com/ourstore/Search/Category/?search_string=dell%20laptop
What I need to do is put a search box in the header, and pass along the search term entered into the search box to the advanded search page, and put the search term into the iFrame's URL.
Is there a way to do this? I'm pretty new to WordPress, but I've been writing PHP code forever. I'm just not sure where to look in WordPress.
If I understand your question, you should be able to use the_search_query();
https://codex.wordpress.org/Function_Reference/the_search_query
This function just outputs whatever the current WordPress search query is. So in your code to call your iFrame, you could do something like this:
<iframe src="https://store.com/ourstore/Search/Category/?search_string=<?php echo get_search_query(); ?>">
Now, since the search term is going to need to be encoded for use in a URL, you can use the PHP function urlencode();
<iframe src="https://store.com/ourstore/Search/Category/?search_string=<?php urlencode(get_search_query()); ?>">

Meta Description Content Not Showing In Google Search Result Page

I think i am having some critical meta tag issue in my website. When i search my website in google, In the search result, Website title and name showing correct information but in place of description some other content is showing which is not the meta description content but some parts of the content of my website's home page. My website is developed in PHP-based opensource opencart.
i searched a lot to resolve it but still i got no solution. I have no previous experience in seo that makes me estimate something without sufficient information to be sure where the error is. If anyone helps me out here that would be really great. I attached an screenshot for better understanding.
Firstly, ensure that you are following the structure which is shown in https://support.google.com/webmasters/answer/79812?hl=en
This means that your tag should look like this:
<meta name="description" content="A description of the page" />
Something that could be causing this problem is that Google does not update descriptions automatically- so you may have to wait until they crawl your website again, for it to update (you could use the Google Webmaster systems to encourage this).
Google will sometimes use the meta description of a page in search
results snippets, if we think it gives users a more accurate
description than would be possible purely from the on-page content
https://support.google.com/webmasters/answer/35624?rd=1
google only sometimes uses your meta description. Other times, it uses page content.

Change facebook meta data based on URL / Anchor

I've discovered whilst typing my question a small exchange on this at Adding a URL hash into meta data for Facebook and Twitter share cards which suggests that this may not be feasible but as things change over time I thought I'd seek guidance.
The scenario:
I have a URL http://example.com/ which includes appropriate Facebook meta in the header. I'm most interested in:
<meta property="og:image" content="whatever.jpg" />
At a later date I may add some additional info on the page and link to it with an anchor - e.g. http://example.com/#new and may want to display different meta for that anchor, e.g.
<meta property="og:image" content="whatever-another.jpg" />
My question is, is there any way to dynamically change the meta depending on whether the URL shared is the original URL or the URL with an anchor. The page could have multiple anchors.
My site uses Wordpress so I can use things like custom fields, etc if they are a possible manual solution but whatever, the ability to change the meta field based on the URL anchor is the goal.
Appreciated any guidance.

Joomla "Link Preview" (like the facebook feature)

I am try to get for my joomla 2.5 website the feature of facebook "preview link". This feature should generate a preview when I enter a link in my article (just like facebook does in the status field). I only need this features for link to text/images not to video.
I found this link but I am having difficulties to understand how I am suppose to implementing it into a joomla website.
Thanks a lot for your help!
To dictate what is used for a Facebook link in your content, you need to make use of the Facebook OpenGraph meta tags.
Take a look at this section of the Facebook Developers site, mainly Section 3: Use proper Open Graph tags.
Link Here
The three you need for what you're after are:
<meta property="og:title" content="MyContentTitle" />
<meta property="og:description" content="Enter your snippet here." />
<meta property="og:image" content="http://myurl.com/images/logo-100x100.jpg " />
You can either statically set these for your website, or manipulate the template files for your articles, and echo out the article titles/images/snippets using PHP.
//EDIT//
After clarification from the comments, the easiest method would be to add tooltips using jQuery/jQuery UI:
jQuery UI Tooltips
You can make the tooltips as large as you like, so you could add a preview of the article that is leads to.
Of course, you'll have to make changes to your site template to add this, and also include jQuery UI/jQuery to your template header, if it's not there already.
In addition to that, you'll need to use PHP to echo the article title, description and image within the tooltip.

Facebook Open Graph- Dynamic Title

I'm developing a social app that requires some Open Graph actions.
I want the meta data tag for the title to be from my database because the name of my action title depends on the user choice.
Is it possible to get the title meta from database, rather than being hard coded? For instance:
<meta property="og:title" content="<?php echo $someTitle ?>" />
Of course it is possible – but how to you want to know what content to put out when?
When Facebook scrapes your URL, your site’s user is not involved. So that means you have to transfer some info via the query string or something; and that would make them different URLs, so you’ll end up with different OG objects as well.

Categories