• CIEH

    (@cieh)


    Can someone help me create a function….Please….

    I want to turn some php code into a function so i can include it within functions.php . Could someone please help me out..

    The aim is to have totally customised keyword metadata and I’m sure this would work.

    I would personally call the function something like ” statickeywords ” or similar.

    Using my chosen method I would have a function for each separate set of keyword metadata so I can use it for specific pages and call for it by … say number i.e. statuckeywords1, statuckeywords2, statuckeywords3 etc as the name for each function so i can then call for the function in the header.php and have custom metadata. This
    would mean I can customise each page individually for maximum optimisation of keywords and description meta.

    To Clarify I want to turn the following code into a function so i can call for it later. This code will be used to display custom keywords (and description) within a page’s metadata.

    I will check what the page is via requesting the url or using the built in wordpress metatags to then display customised meta keywords and description.

    Code :

    <!-- start tags for keywords -->
    <meta name="keywords" content="<?php if(is_single() || is_page() || is_category() || is_tag() || is_archive() || is_paged() || the_post()) {
    			$metatags = get_the_tags($post->ID);
    			foreach ($metatags as $tagpost) {
    				$mymetatag = apply_filters('the_tags',$tagpost->name);
    				$keyword = utf8_decode($mymetatag); // Your filters...
    				echo $keyword.",";
    			}
    		}
    		?><?php the_title(); ?>,Here,go,the,rest,of,my keywords,thanks for helping" />

    This code outputs the keyword tags seperated by commas then outputs the page title using the_title(); then outputs the remaining specified keywords.

    I want to keep the tags in my keywords at all times, and perhaps the page title, but would like to be able to adjust all the other ‘remaining’ keywords. I believe the method i have chosen will work well, but it’s probably a bit of a long way around things. If any one has an alternative suggestion I’d like to hear from you.

  • The topic ‘Create a function to customise meta keywords and description’ is closed to new replies.