You can use wp_head
action to add something to head section. You can change the output according your needs.
<?php
add_action('wp_head','add_meta_des');
function add_meta_des() {
if(is_single())
{
global $wp_query;
$post = $wp_query->post;
$page_id = $post->ID;
$page_object = get_page( $page_id );
$content = wp_trim_words($page_object->post_content,30);
$output="<meta name="description" content="".get_the_title()."--".$content.""/>";
echo $output;
}
}
?>
Related Posts:
- Generating rel=prev and rel=next only on wordpress categories
- Add tags to the section via functions.php
- In a WordPress plugin, how do you output HTML code inside the DOM header? [closed]
- Clean up output added via wp_head()
- How do you completely remove the default header and footer using functions.php?
- Passing a variable via wp_head and then calling it on the page
- get_next_posts_link not working without parameter max_num_pages
- adding custom script to functions file
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- How can I modify the element on all pages?
- New custom menu created. how to apply it?
- How to add link rel tags on paginated posts?
- save_post hook – headers already sent?
- Init hook for header send
- Echo a div to header.php from functions.php
- Hreflang Tags from the Most Recent Post Appearing in Category Page Headers
- Correct way of Enqueue self hosted fonts in sass project
- function syntax is off,
- Taxonomy On Index Page
- Adding A New Widget to WordPress Disables the Existing Widgets
- Function image_send_to_editor returns emty title tag
- Including admin-options.php file in Child Themes
- I see edit instead of read more
- WordPress hooks to call a function inside a construct
- Modified functions.php in Magazine Pro theme of Genesis. 500 error
- require_once() Causing categories and tag pages on dashboard to not refrsh
- How To Show Shortcodes In WordPress Custom Fields?
- WordPress undefined function error on using add_action() in functions.php
- Rewrite rules and the permalink
- Edit meta fields from within template
- How to create admin ajax function for my contact form
- Display ads on post in a particular category
- Why does Featured Images not load in the backed?
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Help with is_page() and calling css for specific pages in a Child Theme
- Custom taxonomy check box now showing up
- Help! Need a different logo on my main page from my other pages
- Set display name from nickname with register process
- RSS feed including post updates
- Does WordPress function replace_hello() exists?
- Class::$template_dir_path=get_template_directory();
- Woocommerce – change order status from on-hold to pending payment
- Get child-pages slugs of current page into js-file
- admin-ajax.php & my wp-admin folder url showing in header
- Child theme style.css didn’t work properly but the Customize Additional CSS did [closed]
- Frontend Feature image upload not work
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Disable links to images only if link is an image
- WordPress – Custom Nav menu for logged in users – Shopkeeper theme
- Change post count on tag/terms pages to 10
- True parameter but jquery register in header and not in the footer with wp_register_script
- Pagination not working on my archive page for a custom post type
- Display page number on custom page title function
- How to use if (is_page_template (”))
- different body classes for each category
- How to override or change function in form.php in a plugin
- Why is style.css not loading through the functions.php
- wordpress function through ajax not being called
- Some code is added automatically to my site’s header – what is it?
- Change the second role depending on the first
- How to assign results to variables?
- How to automatically add custom classes to headings in content area
- How to include a hyperlink in the body text of a custom password protected form?
- Get title from IDs in a string
- Restoring pages in wordpress
- uninstall a theme programmaticlly
- Restricted images only for logged user. (hidden url)
- Could you please correct the code is_admin()
- TinyMCE Multiple Custom Classes Selections
- Setting Active Nav item (of Pages) when you are on a Post with Category
- Function causes edit_post_link to link to the wrong post
- Redirect after login to current URL
- How to disable site title and description when custom header is uploaded on the customizer?
- Surrond h1 entry-title automatically with a span tag
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Only seems to be displaying one child when there are supposed to be multiple
- Return ACF Field value function
- Rest API User Levels
- Best way to add image to recent posts widget?
- adding google analytics via echo or between tags
- How to echo the translated custom field?
- Slider Thumbnail Size Issue [closed]
- same get_posts function works diffrently in tag.php and functions.php
- Only Show One Category Name Per Post
- How to add function to custom fields when page/post has a password?
- How to make an If Else on Excerpt Filter
- Adding an IF ELSE to a function
- wordpress ajax is not working for dropdown selection
- Translation Function missing text-domain [closed]
- Custom shortcode with do_shortcode and substr
- Zip all (original) images from media gallery
- Providing fallback function and allow override by plugin
- Keep js after reload the page
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- How to replace words in my posts and saved new words
- Language Switch Function
- Add array of category IDs to global variable?
- Why might wptexturize have become re-enabled?
- How to debug function file causing white screen