A classifieds site can generate thousands of pages, so “write one description per page” quickly becomes impossible. The durable approach is layered: editor-written text when it exists, carefully chosen listing/category/search context next, and the site description as the final fallback.
What a description can and cannot do
It summarizes the specific page for searchers and other metadata consumers.
Google primarily creates snippets from page content and may use the meta description when it better fits a query.
A meta description is not a ranking guarantee or a place for comma-separated keywords.
Search engines can truncate or replace it based on device and query context.
Unique, accurate page content matters more than manufacturing superficially unique metadata for thin URLs.
First configure the global fallback
In Osclass administration, open General Settings and set a concise Page Description.
Describe the marketplace, primary geography, and genuine listing scope without slogans or repetition.
Configure each supported locale if the installed Osclass/theme/plugin stack exposes localized values.
Confirm the setting in final HTML because a theme or SEO plugin may replace it.
Keep this fallback useful on the home page and any route without richer context.
Build a small metadata plugin
<?php
/*
Plugin Name: Site Meta Descriptions
Description: Page-aware meta description policy for this Osclass site.
Version: 1.0.0
*/
if ( ! defined( 'ABS_PATH' ) ) {
exit;
}
function site_meta_normalize( $value, $limit = 170 ) {
$text = html_entity_decode(
strip_tags( (string) $value ),
ENT_QUOTES | ENT_HTML5,
'UTF-8'
);
$text = preg_replace( '/\s+/u', ' ', $text );
$text = trim( (string) $text );
if ( '' === $text ) {
return '';
}
if ( function_exists( 'mb_strlen' ) && mb_strlen( $text, 'UTF-8' ) > $limit ) {
$text = rtrim( mb_substr( $text, 0, $limit - 1, 'UTF-8' ) );
$text .= '…';
}
return $text;
}
function site_meta_description( $description ) {
$fallback = site_meta_normalize( $description );
if ( osc_is_ad_page() ) {
$candidate = osc_item_description();
$normalized = site_meta_normalize( $candidate );
return '' !== $normalized ? $normalized : $fallback;
}
if ( osc_is_static_page() ) {
$candidate = osc_static_page_text();
$normalized = site_meta_normalize( $candidate );
return '' !== $normalized ? $normalized : $fallback;
}
return $fallback;
}
osc_add_filter( 'meta_description_filter', 'site_meta_description' );The filter returns text; it does not own the head markup
The
ABS_PATHguard prevents casual direct execution outside Osclass bootstrap.strip_tags()removes markup but is not the final HTML-attribute escaping step.Entity decoding followed by whitespace normalization creates human-readable plain text.
Multibyte functions avoid breaking UTF-8 descriptions when shortening.
The incoming description remains the fallback so other Osclass page logic is not discarded accidentally.
Do not cut words in the middle
if ( function_exists( 'mb_strlen' ) && mb_strlen( $text, 'UTF-8' ) > $limit ) {
$slice = mb_substr( $text, 0, $limit, 'UTF-8' );
$space = mb_strrpos( $slice, ' ', 0, 'UTF-8' );
if ( false !== $space && $space > (int) ( $limit * 0.6 ) ) {
$slice = mb_substr( $slice, 0, $space, 'UTF-8' );
}
$text = rtrim( $slice, " \t\n\r\0\x0B,.;:-" ) . '…';
}Character limits are editorial guardrails
The code backs up to a recent space when practical.
mb_*counts Unicode characters rather than bytes.The ellipsis signals truncation, but a complete hand-written sentence is better.
Search snippets have no universal fixed character limit and may be generated from visible content.
Treat frequently truncated listing descriptions as an editorial/data-model problem, not only a string function problem.
Prefer an explicit listing SEO field when quality matters
Listing body text often begins with dimensions, price, greetings, or copied markup rather than a useful summary.
A validated optional SEO-summary field gives trusted publishers editorial control.
Apply length guidance, profanity/policy controls, locale support, and role permissions.
Fall back to a normalized listing description when the field is absent.
Do not expose private contact information, hidden moderation notes, or user email/phone fields in public metadata.
Add category context carefully
if ( osc_is_search_page() ) {
$category = site_meta_normalize( osc_search_category() );
$city = site_meta_normalize( osc_search_city() );
$parts = array_filter( array( $category, $city ) );
if ( ! empty( $parts ) ) {
return site_meta_normalize(
sprintf(
__( 'Browse %s listings, compare details, and contact sellers.', 'site_meta_descriptions' ),
implode( ' in ', $parts )
)
);
}
}Only trusted, indexable facets belong in metadata
Use helper calls supported by the installed Osclass release/theme; search-location helpers can vary.
Translation wraps the stable sentence, while category/city remain page data.
Normalize values before interpolation and escape once at output.
Do not generate indexable copy for arbitrary query strings, user-entered searches, sort modes, or every filter combination.
Canonical, robots, sitemap, internal-link, and description policy must agree on which search pages deserve indexing.
Multilingual sites need locale-matched descriptions
Select listing/static/category text for the current public locale, not the administrator’s locale.
Use translated templates and localized editor fields.
Do not mix English boilerplate with a Hindi, Marathi, Spanish, or Arabic page.
Keep hreflang, canonical URLs, visible content, title, and description aligned by locale.
Fallback to the site description in the same language rather than silently using another locale.
Escape exactly at the HTML output boundary
<?php $description = meta_description(); ?>
<?php if ( '' !== trim( (string) $description ) ) : ?>
<meta name="description"
content="<?php echo osc_esc_html( $description ); ?>">
<?php endif; ?>Inspect before changing the theme
Many Osclass themes already call a metadata helper; modifying it may create duplicate tags.
The filter should return plain text, while
osc_esc_html()protects the attribute context.Do not pre-escape in storage/filter and escape repeatedly—double-encoded entities become visible.
Do not insert raw listing descriptions into
content="..."; quotes and markup can break the head.Use the escaping helper and head convention defined by the installed Osclass/theme version.
One owner must emit one description element
Inventory the theme, SEO plugins, custom plugins, and reverse-proxy/edge transforms.
Choose which component calculates descriptions and which component prints metadata.
Disable or integrate competing emitters instead of relying on source order.
Validate home, listing, category/search, static, authentication, account, contact, error, and pagination routes.
Keep administrative and private pages out of public search through access/indexing controls, not clever descriptions.
Install and activate safely
php -l oc-content/plugins/site_meta_descriptions/index.php
find oc-content/plugins/site_meta_descriptions -type f -maxdepth 2 -printPHP reports no syntax errors and the file inventory shows only the expected plugin files.Risk level: caution. Review the command before running it.
Staging first because metadata is site-wide
php -lchecks syntax, not Osclass helper availability or runtime behavior.Activate the plugin through the Osclass administration interface after backing up files/database.
A fatal callback can affect every public page that renders the head.
Use version control/deployment artifacts instead of editing production through a browser file editor.
Record the supported Osclass/theme/plugin versions and a rollback procedure.
Verify final HTTP and HTML behavior
curl -sSIL https://classifieds.example/listing/example
curl -sSL https://classifieds.example/listing/example | \
python3 -c 'import sys; from bs4 import BeautifulSoup as B; s=B(sys.stdin.read(), "html.parser"); print([(m.get("name"), m.get("content")) for m in s.find_all("meta", attrs={"name": "description"})])'The first request shows status/redirect/canonical destination context; the parser should print exactly one non-empty description tuple.Source verification catches what settings screens cannot
Follow redirects and test the canonical public URL.
Assert exactly one description element—not merely that one exists.
Check quotes, ampersands, emoji, combining scripts, right-to-left text, and long unbroken input.
Verify HTTP status, canonical, robots directives, title/H1, language, and visible page content together.
If metadata is client-rendered, also inspect a rendered browser DOM, while retaining server HTML for reliable discovery.
Build a route test matrix
Home page with configured site description.
Listing with explicit SEO summary, listing-body fallback, empty body, expired/removed state, and malicious markup.
Category and selected location pages that are intentionally indexable.
Arbitrary search, filters, sorting, pagination, and no-results states under the chosen canonical/noindex policy.
Localized variants and missing-translation fallbacks.
Static content, contact, login/register, user dashboard, errors, and private/moderation routes.
Descriptions for expired or deleted listings
Metadata cannot repair the wrong HTTP lifecycle.
A permanently removed listing may warrant 404/410, a useful replacement route, or a policy-specific retained page.
Do not keep an unavailable-item sales description on an error page.
Avoid blanket redirects of every deleted listing to the home page.
Coordinate status, canonical, visible notice, structured data, sitemap removal, internal links, and metadata.
Security and privacy boundaries
Treat all seller/listing/search input as untrusted.
Remove markup and control characters, normalize whitespace, bound processing, and escape at output.
Never expose email addresses, phone numbers, exact private addresses, moderation notes, draft data, tokens, or account information through metadata.
Do not make private pages crawlable merely to show a customized description.
Review third-party SEO plugins and theme updates before granting them ownership of user-generated metadata.
Common failures
Every page shows the site description: filter is not registered, page predicate does not match, or another emitter wins.
Two descriptions appear: theme and plugin both print markup; select one output owner.
HTML/entities appear in snippets: normalization/escaping ownership is wrong or content was stored already escaped.
Fatal undefined helper: example targets a different Osclass/fork/version; inspect installed API and guard/version-test.
Descriptions mix languages: data lookup uses the wrong locale or fallback.
Search spam grows: arbitrary facet/query descriptions were made indexable without canonical/robots governance.
Changes do not appear in search: rendered HTML/cache may be stale, or engines have not recrawled/reprocessed, or selected another snippet.
Core update removes changes: customization was made inside core rather than plugin/theme extension points.
Measure quality instead of presence
Crawl canonical indexable URLs for missing, duplicate, empty, malformed, and multiple tags.
Group by page type and locale so template failures become visible.
Prioritize pages with impressions, business value, poor CTR, or snippets that misrepresent content.
Annotate releases and wait for recrawl before comparing meaningful time windows.
Search snippets vary by query; evaluate qualified clicks and landing-page satisfaction, not only whether your exact text appears.
Release checklist
Original files/database are backed up and customization lives outside Osclass core.
Installed-version helper/filter semantics are confirmed.
One component calculates and one theme boundary safely emits one description element.
Page-type, locale, canonical, robots, status, and data-privacy policies align.
Automated crawl tests cover representative routes and hostile/Unicode inputs.
Cache purge, deployment, monitoring, version compatibility, and rollback are documented.
Primary references
Osclass General Settings documents Page Description, canonical, structured-data, and platform metadata settings.
Osclass filters reference lists
meta_description_filteras the extension point for page descriptions.Osclass GitHub repository is the upstream source for confirming exact filter/helper behavior in a pinned release.
Google snippet guidance explains page-derived snippets, optional use of meta descriptions, uniqueness, and programmatic generation.
Google title-link guidance helps keep title, heading, and metadata signals aligned.
Comments and corrections