• Resolved olofiano

    (@olofiano)


    Hi. I’m running on Wp 3.4.1 and installed the Magic Fields v 2.0.1 plugin. The problem is that it doesnt loop out anything when i call the get() function. I’ve tried these codes amongst many:

    <?php
    $members = get_group('members');
          foreach($members as $member){
            echo $member['members_name'][1]."<br />";
            echo $member['members_position'][1]."<br />";
            echo "<img src='".$member['members_photo'][1]['thumb']."'><br /><br />";
          }
    ?>

    I’ve been putting it within the Loop in one of my custom template files and nothing is shown. I’ve been trying alot simpler codesnippets which are pretty straight forward but no luck with those either. I discovered that $members is an empty array… Any ideas of what could be wrong? I have of course been tripplechecking all fieldnames and so on.

    thanks,

    Olof

    https://www.ads-software.com/extend/plugins/magic-fields-2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter olofiano

    (@olofiano)

    resolved

    Hey Olof,

    Can you please post the code or tell me the why how you fix the issue? I am facing same issue and getting empty array. Please help me and tell me the solutions.

    Thanks in advance.

    Thread Starter olofiano

    (@olofiano)

    I’m not using magic fields anymore, switched to Advanced Custom Fields. But what you need to do is get the posts from the custom type you created using magic fields. This can be done via the post_type parameter in the get_posts() function.

    Then inside the loop use this code for displaying a certain magic field content in a certain place on website:

    global $post; //required
    $temp_post = $post;  //if you need $post further down in code
    
    $args = array(
    'post_type' => 'your custom post type here' , //the post_type created by MF
    );
    
    $custom_post = get_posts($args);
    //do something
    $post = $temp_post;

    Hope this helps!

    Thank you Olof. I really appreciate you for quick and positive response.

    Thanks for the help.

    Cheer!

    Irfan Lateef

    Olof, I am sorry to again disturbing you. Can you please tell me how to get the “meta_value” from $custom_post = get_posts($args); because magic field save the values in meta_value column?

    Thanks In advance! Have a nice day

    $args = array( 'post_type' => 'slides',
    		'meta_key' => 'slideshow_image',
    );
    $slides = get_posts($args);

    I am unable to get “meta_value” in $slides array. Please do help me how can I get meta_value from the $slides array using magic fields.

    Thread Starter olofiano

    (@olofiano)

    You can try using the meta_query instead. Something like this:

    $args = array(
    	'post_type' => 'slides',
    	'meta_query' => array(
    				'key' => 'slideshow_image',
    				'value' => 'the value'
    					)
    		);

    This will return all posts from post type slides with meta_key ‘slideshow_image’ and meta_value ‘the value’. After this just use the MF built in functions of getting the fields!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Magic Fields 2.0.1 doesnt show anything’ is closed to new replies.