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
- Function to update post_meta based on existing post_meta
- Load jquery only for certain pages in the backend
- check if the user is owner of current page
- allow only one post in specific category
- ACF not showing
- How to set the default avatar of buddypress avatar [closed]
- Custom styles.css sheet for visual editor
- Use html inside shortcode function
- Publishing just a Facebook URL without full code snippet
- Filter an WordPress Function in (general-template.php)
- linking stylesheets and scripts with functions.php
- attachment page template? only show attachments for current post?
- Conditional statement not working in function
- Unable to return values from function
- Remove the month and year from a WordPress Date?
- Show some menu sub items as dropdown under a menu item
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to insert class in each list of categories?
- The correct way to add a JavaScript in the functions.php [closed]
- How to remove some item from WordPress Dashboard for user Author
- processing form data with ajax
- Check from functions.php if function exists in footer.php
- How to make a new function that includes a template
- Disabling Author Page only for subscribers
- Showing user profile data on front-end
- How to register a menu based on a ACF condition
- How to convert raw url to hyperlink?
- Split single-review.php to two parts
- Breaking up multiple words and inserting an image after first word
- get content from page through AJAX
- Why is this function crashing my wordpress installation? [closed]
- colorbox not loading in
- The work of WordPress Function update_post
- Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()
- how can I change all wordpress media file url to custom cdn url?
- Changing the HTML of notices in WooCommerce [closed]
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- How to Override Page Template if URL matches query?
- Save_post – Warning: Cannot modify header information
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- How Can I Create a Friendly Slug for a Dynamic Page?
- Woocommerce Display Discount On cart
- Modify content inside post before first publish
- Pass an argument into a function to extract from array
- function class doesnt work
- how to remove a tag in the_category function
- Load CSS file conditionally
- my wordpress doesn’t save items to customized widget area
- Remove all video attachment, both files and post/postmeta from database?
- Copying a widget class to functions.php results on a blank page
- save_post doesn’t correctly process function call with php class
- How to create admin ajax function for my contact form
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- Changing the register url is not working
- Newest comments first not working
- Pass arguments to function class with do_action()
- How to a override parent theme page that has been included with require_once?
- Display most popular posts
- how to display featured image for single post for a specific category
- Database Query not working
- Can I use a function to return HTML and the result of another function?
- Dynamically generated Navigation Diagram using Custom Fields
- Excerpt length: get 2 paragraphs
- Remove heading tags on line break
- How to use WP_rewrite?
- Wp get archive only text not link
- Full size image option removing problem
- can not call functions in function.php
- Add custom fields after post/page title
- Ajax call does not work for this custom code
- Force resize for all video content
- Sort results by name & asc order on homepage
- Add the title of a widget as an ID – for anchor links
- Display post_meta-by_key on product catalogue
- What are the parameters are used in add_action and filters?
- I want to add the alt attribute to all the photos!
- Does functions.php apply to every page?
- Creating mixture of shortcodes to use in the visual/text editor
- Correct php syntax to add an image in wp functions.php
- Is storing in a variable the result of a fonction a most powerful way to code an if structures in WordPress?
- Add functionality to block comment authors in the Comment edit pag
- WordPress enque the same script causes the setInterval not to work
- Need help adding currency conversion to this code
- Abbreviate WordPress post view numbers
- Override categories with Pages (block theme)