Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to build a list of partners. At the moment, I have tried with the "links" function, the problem is that I can't use html tags on the description field. Therefore I'm looking for another solution. Anyone has a suggestion?

share|improve this question
1  
I don't think this site does plugin recommendations anymore. I'm sure someone will correct me if I am wrong. I show a list of sponsors on my own site just in a hard-coded array then a foreach loop. No admin UI though. Let me know if you'd like to see that. –  helgatheviking Mar 5 '13 at 19:58
    
@helgatheviking yes please, I'd like to see it. What is the problem with plugin recommendations? there are so many plugins, and it's difficult to search for the right one if you don't know what exactly is the name of the "problem". –  otmezger Mar 5 '13 at 20:10
    
We indeed don't do plugin recommendations, which can be read in the faq. –  Camil Staps Mar 5 '13 at 20:12
1  
You could just go the route of creating a custom post type that allow everything you're looking for. It's not terribly difficult and could be done with a little bit of coding to your functions.php. You'd then be able to style the output using page templates and CSS –  NW Tech Mar 5 '13 at 20:16
    
I took the liberty to rewrite the question slightly, so it can stay open. –  toscho Mar 5 '13 at 20:16
add comment

3 Answers

As NW Tech commented you should use a custom post type for it. Check codex for register_post_type.

You could try something like this:

function partners_custom_init() {
  $labels = array(
    'name' => 'Partners',
    'singular_name' => 'Partner',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Partner',
    'edit_item' => 'Edit Partner',
    'new_item' => 'New Partner',
    'all_items' => 'All Partners',
    'view_item' => 'View Partner',
    'search_items' => 'Search Partners',
    'not_found' =>  'No Partners found',
    'not_found_in_trash' => 'No Partners found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Partners'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'partner' ),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
  ); 

  register_post_type( 'partner', $args );
}
add_action( 'init', 'partners_custom_init' );

With that piece of code in functions.php you will be able to add partners as you add posts or pages.

You dont explain where do you want to show the results. You can use custom post type templates or a custom query anywhere in your files to show them.

share|improve this answer
    
Thanks, I'll look into it. –  otmezger Mar 8 '13 at 8:27
add comment

As promised, here's the hard-coded solution I used in the past. However, as a caveat I would have to say I definitely prefer the custom post type solution. If I get a chance, I will probably go back and implement it myself.

//edit here to add/remove sponsors
// array('Sponsor Name','name of logo in images folder','url of sponsor site')
$sponsors = array(
                array('Sponsor 1','logo1.jpg','http://www.site1.com'),
                array('Sponsor 2','logo2.png','http://www.site2.com'),
                array('Sponsor 3','logo3.png','http://www.site3.com'),
                array('Sponsor 4','logo4.png','http://www.site4.com')
            );

$src = get_stylesheet_directory() . '/images/logos/';

?>
<div id='sponsors'>

    <?php $i=1;
        foreach ($sponsors as $sponsor) {
            echo '<a target="_blank" class="sponsors" href="'.$sponsor[2].'" title="'.$sponsor[0].'">
      <img class="color" src="'. esc_attr( $src .$sponsor[1] ).' alt="'.$sponsor[0]. ' Logo" class="sponsors" /></a>';

            $i++;
        } ?>

</div>
share|improve this answer
add comment

Although it's being kind of "deprecated" in favor of Custom Post Types (I believe it won't be possible, due to backwards compatibility - relevant core ticket), I like the Links functionality.

The following code allows HTML tags in the Description field, and also in the Notes field (as it is a big textarea instead of the single line text field for Description).

remove_filter( 'pre_link_description', 'wp_filter_kses' );
remove_filter( 'pre_link_notes', 'wp_filter_kses' );

add_filter( 'pre_link_description', 'wp_filter_post_kses' );
add_filter( 'pre_link_notes', 'wp_filter_post_kses' );

It can be pasted in the theme's functions.php file, but it's better placed as a standalone plugin (so, it's theme independent).
See this Q&A: Where to put my code: plugin or functions.php?

This plugin may also be of interest, I did it based on a WordPress Answers topic: Featured Link Image.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.