• Resolved gttygrl

    (@gttygrl)


    I’ve added the plugin, and successfully added meta description and keywords to my pages that appears just fine in the front-end source. I’m now trying to retrieve the description to appear in the search results, and I’m getting nada.

    This is my code so far:

    <a href="<?php the_permalink(); ?>" class="text-wrap">
    <h4><?php the_title(); ?></h4>
    <p>
    <?php 
    $meta_print_value=get_post_meta(get_the_ID(),'description',true);
    echo $meta_print_value;
    ?></p>
    </a>

    But all it’s returning is the title, no description.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter gttygrl

    (@gttygrl)

    I’ve dug in further, and retrieved this array:

    Array
      (
        [mtm_data] => Array
          (
            [0] => a:2:
              {
                i:0;
                a:4:
                  {
                    s:9:"reference";
    		s:0:"";
    		s:4:"type";
    		s:4:"name";
    		s:5:"value";
    		s:11:"description";
    		s:7:"content";
    		s:61:"my description text";
    	  }
    	 i:1;
    	 a:4:
    	   {
    	     s:9:"reference";
    		 s:0:"";
    		 s:4:"type";
    		 s:4:"name";
    		 s:5:"value";
    		 s:8:"keywords";
    		 s:7:"content";
    		 s:91:"my keywords text";
    	    }
    	  }
        )
      )

    I can get to the mtm_data array, but I still can’t retrieve the description text. This is my latest try:

    $meta_print_value=get_post_meta(get_the_ID(),'mtm_data',true);
    echo $meta_print_value[0][1][7];

    It returns nothing. But, when I just echo “$meta_print_value;” it prints “Array”, so at least I know I’m in the right neighborhood.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I’d suggest you check out the file meta-tag-manager.php

    The main function you want are:

    Meta_Tag_Manager::get_data(); //all global tags
    Meta_Tag_Manager::get_post_data($post_id); //specific post tags

    They both return arrays of MTM_Tag objects.

    Thread Starter gttygrl

    (@gttygrl)

    Thanks for replying! I’ll try it and let you know.

    Thread Starter gttygrl

    (@gttygrl)

    Got it!

    echo $meta_tags[0]->content;

    Thanks!

    Thread Starter gttygrl

    (@gttygrl)

    Closing.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I retrieve the meta info in a template?’ is closed to new replies.