• Resolved LenMatts

    (@lenmatts)


    Im having a little bit of a hard time outputting the data in its correct format.

    I created a custom content type “Professor” with the following fields, title, school & department. School is a dropdown list being generated via a sql from another custom content type Schools. Now when I try to display the professor content via single-professor.php its all good if i display it as it is as a text here’s a sample how can I do it that the school will be displayed as a link and when the user clicks the school they will be directed here

    thanks in advance.

    https://ww.wp.xz.cn/plugins/custom-content-type-manager/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor fireproofsocks

    (@fireproofsocks)

    Links to the end result are generally not useful in diagnosing PHP: it’s more helpful to see the PHP code that was used to generate the HTML.

    Output filters are available only as a convenience, and there’s no requirement that you use them. I’m not sure how your SQL query looks, but the most “correct” solution (from a data-normalization standpoint), is to select the name as the visible option and the post ID as the stored value (because the ID never changes). Then the task is to convert the stored ID to whatever data it is you wish to display (e.g. the post_title, the permalink, the thumbnail etc). Once you’re sure you’re storing the post ID, then the crux of the problem is “how do I convert a post ID into the data represented by that post?” Variations on that question come up so often that I’ve devoted several of the FAQ’s to them: https://code.google.com/p/wordpress-custom-content-type-manager/wiki/FAQ

    Relatedly, a custom SQL query may not be necessary if you define your field as a relation field: it provides a GUI for you to specify criteria for searching the posts table specifically.

    Hope that helps.

    Thread Starter LenMatts

    (@lenmatts)

    FPS, thanks for the reply…been reading the FAQ’s and followed everything to the bit..my sql is the same as the example form the FAQ

    here’s the sql how i generated the dropdown for custom field school in custom type professor

    SELECT post_title, ID
    FROM [+table_prefix+]posts
    WHERE post_type='school'

    now here’s how presented it on the single-professor.php

    <td valign="top">
      	              School : <strong><?php print_custom_field('schools'); ?></strong><br />
    	              Department/College : <strong><?php print_custom_field('department'); ?></strong><br /><br />

    how can I make the school to show as a link to its corresponding page?

    thanks a lot really appreciate your help..

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    It’s in the FAQ, all comes down to “how do I convert a post ID into the data represented by that post?”

    https://code.google.com/p/wordpress-custom-content-type-manager/wiki/FAQ#My_Image/Relation/Media_Field_Only_Shows_Numbers._WTF?!?

    https://code.google.com/p/wordpress-custom-content-type-manager/wiki/to_link_OutputFilter

    E.g.

    <strong><?php print_custom_field('department:to_link'); ?></strong>

    Or for heavy artillery:

    https://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_post_OutputFilter

    Thread Starter LenMatts

    (@lenmatts)

    FPS thanks for pointing me to the right direction!! Plugin is really great! this really opens up a lot of possibilities for wordpress!!

    many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Output filters’ is closed to new replies.