at the moment, the plugin won’t do what you are after.
You can achieve the link with some very simple php.
you could loop through the rows and use a php echo to display something like this:
echo ‘url.'”>’.$row->name.’‘;
good luck.
echo '<a href="'.$row->url.'">'.$row->name.'</a>';
Thread Starter
swgt5
(@red001)
can’t get it to work. I have
<?php echo ‘url.'”>’.$row->name.’‘; ?>
I cant read the code you posted correctly. Can you post the code somewhere else and link me to it?
Thread Starter
swgt5
(@red001)
hey mate.
I can see why it’s not working. I wrote $row->url as an example. It won’t work with your code as you have called your variables different names (which is good).
in your case:
$row should be $image,
->url should be what ever your called the column name
does that make sense?
Thread Starter
swgt5
(@red001)
yes thanks – worked perfectly
I am getting the same error. I’m using version 1.1 of the plugin, with WordPress 3.1.
Warning: Invalid argument supplied for foreach() etc
<table>
<tr>
<?php foreach(get_cf_matrix('Smile') as $image): ?>
<td><img src="<?php echo $image->smile_url; ?>" width="200" alt="<?php echo $image->smile_alt; ?>" /></td>
<td><?php echo $image->smile_caption; ?></td>
<?php endforeach; ?>
</tr>
</table>
That is the code I have in my custom template. I’m using a custom post type, but I’m not sure that is affecting anything. I have a query for the custom post type, but I get the same result when I use the query or not. I did change the column titles, and used copy and paste to make sure they are the same as I have set up. “Smile” is the title of the matrix I set up.
I’m out of things to try. I’m convinced this is exactly what I need, but I’m close to giving up. Any ideas?
Hey mate
your code looks good so I’m guessing the problem lies with the $post object.
Basically, the get_cfm function is looking for your data in the wrong location.
* you can now change the function from get_cf_matrix to get_cfm
either use the setup_postdata($post); to setup the post object properly or enter a second parameter in the get_cfm function
eg.
get_cfm(‘Smile’,$custom_post_type->ID)
Hope that helps.
If not, post all your code somewhere and link me to it.
Wow, that was fast. One teensy bit of code between a great plugin and amazing service. I’ll need to post the code, because I’m getting the same result. One quick question, though. Should I have registered the plugin anywhere? My server does not always accept WordPress writing to the server. I can’t see where that could come into play, but thought I should mention it.
never heard of having to register a plugin. That shouldn’t be a problem.
Can you post the code somewhere?
I can’t expose the url as I am working on a client file, so I will have to post it here. This is the template file for the page I am trying to display the matrix on.
Note: I have the loop endwhile commented out — I always seem to have to do that. Related. I haven’t had any trouble with it otherwise. This is actually the third site I’ve done that for.
The custom post type is smile.
<?php
/**
Template Name: Smile
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<div id="shadow"> </div>
<div class="breadcrumbs">
<?php
if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>
<?php query_posts(array('post_type'=>'smile')); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<table>
<tr>
<?php foreach(get_cfm('Smile',$custom_post_type->ID) as $image): ?>
<td><img src="<?php echo $image->smile_url; ?>" width="200" alt="<?php echo $image->smile_alt; ?>" /></td>
<td><?php echo $image->smile_caption; ?></td>
<?php endforeach; ?>
</tr>
</table>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php comments_template( '', true ); ?>
<?php //endwhile;
// end of the loop. ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
aahh
your code is not using the $post object at all.
you are missing the loop in your template.
The loop sets up the $post object which is needed for the cfm plugin to work. read more here:http://codex.wordpress.org/The_Loop
the loop code will also be present in the page.php file.
One of these days, I will cut and paste myself into insanity. For as hard as I have stared at this code, I was not seeing that. It’s working. Thank you so very, very much. Now I can move to my comfy place — CSS.