• Hello,

    I need help to create a custom field for related post.
    I would like to choose in one list whish contain all the post of my blog (the id and the title or only of them).
    In my post, I would like to show the title of the related post and when I clic on it, I go to the post

    Thanks for your help
    Excuse my english
    Julien

Viewing 4 replies - 1 through 4 (of 4 total)
  • Do you want this field to be a select list from which you can pick on related post?

    yes I would like this, related post from my website…
    Do you have an idee to help me ?

    Thanks
    Julien

    Here’s some code for the field that goes in the template definition section:

    [Related_Post_ID]
    type = select
    code = 0
    hideKey = true
    label = Related Post

    The attribute code = 0 references the PHP code section further down the page. The following code should go in the PHP Code section, in the Code #0 box.

    global $wpdb;
    $items = $wpdb->get_results("SELECT ID, post_title
    FROM $wpdb->posts
    where post_type = 'post'
    and post_status = 'publish'
    order by post_date DESC");
    $i = 0;
    foreach ($items as $item) {
    	$values[$i] = $item->ID;
    	$valueLabel[$i] = $item->post_title;
    	$i++;
    }

    If all goes well, this will give you a dropdown list of all your posts.

    Is there any “real” manual for this? Where can you look up things like that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Custom Field Template] Manual Related Post’ is closed to new replies.