ZigPress

Words about WordPress from Malta

ZigConnect

post-plugin-zigconnect
Minimum WordPress version: 3.0.4
Tested up to: WordPress 3.3.1
Minimum PHP version: 5.2.4
Minimum MySQL version: 5.0.15

One feature sadly lacking in WordPress is the ability to directly link posts or pages (or indeed any content type) directly to each other in a flexible relationship, and to store data with each link.

If that sounds a little confusing, think of this example:

  • You run a comparison shopping website
  • You have a custom post type called ‘product’
  • You have a custom post type called ‘shop’
  • You want to show on the product pages where they can be bought, and you also want to show on the shop pages a list of which products are available there
  • Not only that, each product is a different price at each shop, so you need to store and show a different price for each ‘product to shop’ link.

If you’re using WordPress as a CMS, rather than just a blog, you’ve probably encountered this need and cursed WordPress for not meeting it.

A few of you may be aware that there is already a plugin to address this need, called Posts 2 Posts. However, it contains serious bugs that prevent the storage of data with links between posts, and it also demands extensive PHP customisation to store any data at all. Posts 2 Posts has now been updated with many improvements – feel free to give it a try. I have not tried the new version myself since I have no need to.

ZigConnect

Enter ZigConnect. It has been created from scratch to do what Posts 2 Posts aims to do, but without the need to fill your functions.php file with custom code.

Not only that, it lets you define both connections (between content types) and fields (attached to connections) using the administration console, and gives you handy statistics so you can see how heavily you are using it.

Displaying link-related information within posts is done using a little PHP code with some simple template tags that you can put into your template files. After installing the plugin, pull down the ‘Help’ tab for information about the template tags.

Please use the comment form below to report any bugs you find. Updates are likely to be frequent due to ongoing ZigPress projects that rely on this plugin.

Installation

  1. Go to Admin > Plugins > Add New, and type ZigConnect in the search box to get the download link.
  2. Activate the plugin.
  3. Go to the plugin’s main page and start creating connections between content types.
  4. When editing posts, pages or custom posts, use the extra ZigConnect panels to create links.

ZigConnect is a free plugin released under the GNU General Public License version 2.

If you use ZigPress plugins and find them useful, please consider donating or sharing a link.

UPDATE: 7 DEC 2011

The site I originally built ZigConnect for has changed direction somewhat and I have substantially altered ZigConnect’s functionality as a result. I don’t have time to continue supporting the public version of ZigConnect; however, if anyone would like to take the current version and create a fork, you’re welcome to do so.

42 Comments

  1. Hi,

    Thanks for a great plugin but I can not get it to work with the template tags. What am I doing wrong? can you please see my screenshot. ( https://skitch.com/vifa/rqns5/dreamweaver )

    Thanks in advance.

    Regards // Daniel

  2. Hi Daniel,
    The zc_get_linked_posts() template tag simply returns an array of post IDs of the posts that are linked to the current post. You have to then loop through the array, get the post info, and then render links as appropriate.
    Here’s an example (it must all be within PHP tags, and please convert the smart quotes back into simple ones):-

    $connectedposts = zc_get_linked_posts(‘my_type’);
    if ($connectedposts)
    {
    echo ‘<ul>’;
    foreach ($connectedposts as $otherpostid)
    {
    $otherpost = get_post($otherpostid);
    echo ‘<li>’;
    echo ‘<a href=”‘ . get_bloginfo(‘url’) . ‘/my_type/’ . $otherpost->post_name . ‘”>’ . $otherpost->post_title . ‘</a>’;
    echo ‘</li>’;
    }
    echo ‘</ul>’;
    }

    Obviously you should replace ‘my_type’ with the post type that you want to show linked posts for. This example also doesn’t take account of any fields you may have set up on the connection.

    With the next release of this plugin (coming soon), I will add proper examples to the readme file!

  3. I’m getting the following error when trying to activate this as a newly installed plugin:

    Plugin could not be activated because it triggered a fatal error.

    Fatal error: Cannot redeclare upgrade_all() (previously declared in /home2/indeep/public_html/wp-admin/includes/upgrade.php:381) in /home2/indeep/public_html/wp-admin/includes/upgrade.php on line 450

  4. I figured out the above issue. It was a conflict with the ‘Featured Post’ plugin. I deactivated it and it allowed ZigConnect to activate.

    I’m able to set up connections now, but when I hit update on a custom post type with connections, I get the following:

    Warning: Invalid argument supplied for foreach() in /home2/indeep/public_html/wp-content/plugins/zigconnect/zigconnect.php on line 165

    Warning: Invalid argument supplied for foreach() in /home2/indeep/public_html/wp-content/plugins/zigconnect/zigconnect.php on line 165

    Warning: Cannot modify header information – headers already sent by (output started at /home2/indeep/public_html/wp-content/plugins/zigconnect/zigconnect.php:165) in /home2/indeep/public_html/wp-includes/pluggable.php on line 890

  5. Hi John,
    I’ve been travelling but am back at base now, and will issue a bugfix release during the coming week.

  6. 0.3.1 now released, which should fix both the bugs described above by John Cole.

  7. Hi Andy, I installed version 0.3.1 but when I made a connection between posts and pages appeared this message “Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\wordpress_prueba\wp-admin\admin-header.php:19) in C:\xampp\htdocs\wordpress_prueba\wp-content\plugins\zigconnect\zigconnect.php on line 516″ Do you know what does it mean? Thank you!

  8. I believe it’s a conflict with another plugin, however there is a way that I can make ZigConnect play a bit safer to avoid it. Expect another release soon.

  9. Hi Andy,
    Thanks for the example. Saw an error which I corrected in row 5. Could be good because I guess it’s more than me who are not whiz at PHP and just do a copy and paste. :-)
    Instead of
    foreach ($connected as $otherpostid)
    it should be
    foreach ($connectedposts as $otherpostid)

    Sincerely,
    Daniel

  10. Thanks Daniel – I’ve now corrected the code in my original comment to avoid confusion.

  11. Can you set up multiple connections? For example, I am trying to set up a database of artists and artwork. I want to be able to connect these two custom post types. I want it to be that when you are looking at an Artist, a list of ALL of the artwork they are connected to can be displayed.. And when you look at any one of those artworks, the related artist will appear. Is that possible?

  12. Ezra: that is the primary purpose of this plugin :) Just set up a connection between your “artwork” and “artist” post types, and tick the reciprocal box to make it work in both directions. Then start customising your theme’s “single” pages.

  13. Hello, I’m testing your plugin and it lacks some information for “basic users”.The “help” tab is not easy to find as… it’s automatically translated in current language (“aide” in french !) and it’s so tiny.
    I created a link postpage and put

    $connectedposts = zc_get_linked_posts('post');
    if ($connectedposts)
    {
    echo '';
    foreach ($connectedposts as $otherpostid)
    {
    $otherpost = get_post($otherpostid);
    echo '';
    echo 'post_name . '">' . $otherpost->post_title . '';
    echo '';
    }
    echo '';

    The list showed up so I was happy. Looking at the options I saw the “field” option. For testing, I created a field called “test”, associate it with postpage… and my links just disepeared ! Don’t know how to get them back ?!? Deleting the field did not bring back the list… What is exactly the use of these fields ? It’s difficult for me to understand.

  14. Sorry I should have put “page” instead of “post” and the list is here again. But the question remains the same for the fields.

  15. OK ! I just managed the fields. Sorry for all the comments, you can delete them. But maybe some more explanations could be a good idea (I think about the “post” “page” thing).

  16. Hi Li-An,

    Glad you managed to get it sorted.

    The plugin isn’t actually aimed at “basic users”, it’s aimed at WordPress developers with some experience who just want to save some time.

    However, I will try and improve the documentation when I have time.

  17. Thank you! This is a great plugin, it really saved me time!

  18. Awesome plugin, just needed this for a project!
    Btw, works fine with wp 3.1.2.

  19. Hi, thanks for the plugin. Important to know: allow_url_fopen has to be activated. Otherwise you cannot activate the plugin.

  20. @Andreas Renggll
    fopen is a security leek, dont enable if you dont have to.
    for fixing the activation error just replace in the zigconnect-tablebuilder.php
    file_get_contents($objZigConnect->PluginFolder . ‘sql/zigconnect.sql’);
    with:
    file_get_contents(WP_PLUGIN_DIR . ‘/zigconnect/sql/zigconnect.sql’);

    instead of an url it uses a path and you dont need to activate fopen.

  21. dont get how to handle a oneway (post => post) connection.
    example connection:
    post fruit ==> post apple
    on fruit single.php the post apple appears an also on apple single.php the post fruit appears, but it shouldnt cause the connection was declared oneway….

    Im using the example in the readme.txt.

    so what i need to do to establish a simple oneway post => post connection?

  22. as noted on WP Codex, plugin does not work when WP lives in a subdirectory. this might also be causing the error messages that prompted @Andreas Renggli to allow fopen. has anybody seen the developper around recently ????

  23. @philo

    I’d rather fix the object:
    $objZigConnect->PluginFolder = $WP_PLUGIN_DIR . ‘/zigconnect/’

  24. @philo

    $this->PluginFolder = WP_PLUGIN_DIR.’/’.str_replace(basename( __FILE__),”",plugin_basename(__FILE__));

    seems to be the right syntax to make the errors go away and the plugin to work (except for images; these are still broken)

  25. however … in 3.2 adding connections to posts does not work (searchform broken?)

  26. I try to connect different post_type, from book to authors. I put the code in the page single-books.php but nothing seems to work :(
    I’ve try to create a connection between the custom post_type and another different post_type putting the code in single.php, and work with charme… Do I miss something? Do the code work out the single.php page? Thnks

  27. @Peter: developer here :)

    I’ve been offline for a while due to illness; however I will be taking a fresh look at some of these comments over the next few days, and will probably publish a new release once I have ensured compatibility with WordPress 3.2.

  28. ZigConnect 0.8.4 is now released and I have verified compatibility with WordPress 3.2.1.

  29. Hello,

    I would like to ask you to remove your remark about the Posts 2 Posts plugin, since it’s not valid anymore, since version 0.7:

    http://scribu.net/wordpress/posts-to-posts/p2p-0-7.html

  30. @scribu: Done.

  31. Thanks.

  32. Subfolder and allow_url_fopen issues are fixed on 0.8.6.

  33. [...] For further information and support, please visit the ZigConnect home page. [...]

  34. Hi

    Is it possible to query posts by its connections?

    I mean for example.

    Query posts linked to $some_post_id ?

  35. To complement my last question.

    For an example see how post2posts handles this via wp_query class:

    `$connected = new WP_Query( array(
    ‘post_type’ => ‘post’,
    ‘connected’ => get_queried_object_id()
    ) );`

    I already have my content setup wit ZiGconnect is this possible somehow?

  36. Hy Andy,

    first: thank you for this great plugin!

    I’ve got the problem, that connections made by other users than Admins won’t save. I use WP 3.2.1 with multisite option. Do you have any idea?

    Andreas

  37. It appears that editors do not have the ability to remove connections, although this works fine for admins. How can I enable editors to remove connections?

    I’m using WordPress 3.1.4 and Zigconnect 0.8.6.

    Also, I have the User Role Editor plugin (http://wordpress.org/extend/plugins/user-role-editor/) installed, but I’m not sure which capability would allow an editor to remove a connection.

  38. @ Andreas & mrengy: the plugin is designed for use by admins and has not been tested on Multisite. Neither of these things is likely to change in the near future.

  39. Workaround for allowing editors to remove connections described here: http://wordpress.stackexchange.com/questions/29434/zigconnect-plugin-allowing-editors-to-remove-connections

    The thing is – in the current version, editors can see the ZigConnect field when editing a post, and they can set connections – they just can’t remove them.

  40. Please see the new comment at the end of the post – regretfully ZigConnect can no longer be supported.

  41. Hi, can we allow user’s to connect posts from front end while inserting a post??

    is it possible??

    thanks
    raj

  42. Hi,
    Great Plugin. but not working on multisite. Could you please update it for multisite?
    Thanks

Add a Comment


Including links is the best way to get your comment automatically marked as spam...