Forums

add Custom Field to Inline Post plugin (1 post)

  1. Damon Cook
    Member
    Posted 3 years ago #

    I'm using Aral Balkan's Inline Post plugin to embed multiple posts in pages. This is fine and dandy, but I'm now trying to figure out how to add a custom field to the Inline Post's custom loop?

    Here is all 94 lines of code from Balkan's Inline Post (sorry!):
    <?php
    }

    //
    // Actual functionality
    //

    function includePosts ($content = '')
    {
    // Get the Post IDs to include. Post IDs are in the form [nnn].
    preg_match_all('/(?<=\\[\\[)\\d+?(?=\\]\\])/', $content, $matches, PREG_PATTERN_ORDER);

    // Create a table of contents for the top of the page.
    $tableOfContents = '<ul class="toc">';

    $numMatches = count($matches[0]);

    for ($i = 0; $i < $numMatches; $i++)
    {
    $titleTag = get_option('inlineposts_title_tag');

    $postId = $matches[0][$i];
    $post = get_post($postId);

    $anchorTag = '';

    $linkToPost = '';

    $topLink = 'Top';

    $postTitle = $post->post_title;

    // Update the table of contents
    $tableOfContents .= '

  2. '.$postTitle.'
  3. ';

    $postTitleText = "<$titleTag>$linkToPost$postTitle$anchorTag</$titleTag>";
    $postBodyText = format_to_post($post->post_content);

    // Display the edit link next to topic headers if user has edit permissions.
    $canEdit = false;
    $editLink = '';
    if (current_user_can('edit_page', $postId))
    {
    $file = 'page';
    $canEdit = true;
    }
    if (current_user_can('edit_post', $postId))
    {
    $file = 'post';
    }

    if (!is_attachment() && $canEdit)
    {
    $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$postId";
    $editLink = "Edit individual post.";
    }

    //Text to display = Post Title, Last Modified, Comments
    //$text = $postTitleText.'<small>'.$lastModifiedText.' '.$commentsText.'. '.$topLink.'. '.$editLink."</small>".$postBodyText;
    //modified DAC - 12/18/08
    $text = $postTitleText.$postBodyText;

    // Remove comments and any line breaks before the tags
    // so that these don't cause WordPress to insert extra
    //
    tags.
    $content = preg_replace('/<!--.*?-->/', '', $content);
    $content = str_replace("\r\n[[", '[[', $content);

    // Replace the post placeholder with the actual post.
    $content = str_replace("[[$postId]]", $text, $content);
    }

    $tableOfContents .= '';
    $attribution = get_post_meta($postId, 'Attribution', $single = true);
    // Add top anchor
    $content = ''.$content;

    // Add the TOC if user requested it
    $content = str_replace("TOC", $tableOfContents, $content);

    error_log($tableOfContents);

    return $content;
    }

    //
    // Hooks
    //

    add_action('admin_menu', 'addAdminPage');
    add_filter('the_content', 'includePosts', 1);

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags