• Hello, i have problem with puting meta tags in head.
    i’m looking for plugin where i can in my CUSTOM page use some shortocde like:
    [code]<meta .... />[/code] and that code embed in head.

    I googled a lot and i have nathing. I tried with add_action(‘init’,’myfunction’); but don’t work for me (i put in funciton.php)

    i need this for two things setcookie() and for SEO meta tags.

    Any help with this?
    i also tried with searched about some wp functions but i didn’t have luck.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    I can recommend you https://www.ads-software.com/plugins/addfunc-head-footer-code/
    It’s lightweight, stable, works well for this purpose.

    Moderator bcworkz

    (@bcworkz)

    You will have trouble setting cookies in header.php, the latest one can realistically set cookies is when the “send_headers” action fires.

    You can set meta tags from the “wp_head” action.

    Thread Starter DjrodjeB

    (@djrodjeb)

    Thank you for answers
    @petar i need dynamiclly set cookie and seo meta tags for my custompage.php?id=4324
    @bcworkz i tried for wp_head like this:

    add_action("wp_head","mySEOfunction",10,2);
    function mySEOfunction($name,$value) {
    echo "some meta tags...".$name...
    }

    but i have missing 2 argument

    Moderator bcworkz

    (@bcworkz)

    Remove the 4th parm in add_action() (the 2) and both of your callback function’s parms $name,$value

    wp_head does not pass any parms. If you need $name declare it global. Yeah, globals are sneered at, but it’s the easiest option here.

    Hi there,

    When you add an action to a hook like wp_head, the arguments that are passed to that function are not specified by you – they are part of the wp_head action. Therefore, you’ll need to evaluate $name and $value in some other way (for example, from custom post meta or programmatically)

    Something like this:

    function mySEOFunction(){
       $page = get_queried_object(); // assume we are on a page, or use conditionals to check
       if ($page->ID == 234){
        echo "<meta name='whatever' value='{$page->post_title}'/>";
       }
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Embed code to head’ is closed to new replies.