Inline Posts is making all post text a link!
-
I have a big problem…….i edited inline posts in the Editor (I do not want visitors to see the Last Modified On, etc. stuff) and now that I did, it seems like the entire article – or at least the beginning – is part of the post title link….did I remove something I shouldn’t have?
Here is an example of what happens on this page right here. If you go straight to the text and hover over it you will see that it becomes underlined. If you hover over the Post Title, and then just work your way down the page, you see that it stays showing the URL of the original post:
https://outsidervocals.com/alternative-indie/
And here is all the code that is in the inline page editor screen…..can someone please tell me if I took a character out I shouldn’t have? Thanks!
<?php
/*
Plugin Name: Inline Posts
Plugin URI: https://aralbalkan.com/wordpress/
Description: Allows you to include posts in pages (and in other posts). To include a post, just enter its ID in square brackets in the body of a page or another post (e.g., 42).
Version: 2.1.2.g
Author: Aral Balkan
Author URI: https://aralbalkan.com
*///
// Options/admin panel
//add_option(‘inlineposts_title_tag’, ‘h2’, ‘The tag you want the titles of posts to appear in.’);
// Add page to options menu.
function addAdminPage()
{
// Add a new submenu under Options:
add_options_page(‘Inline Posts Options’, ‘Inline Posts’, 8, ‘inlineposts’, ‘displayAdminPage’);
}// Display the admin page.
function displayAdminPage()
{if (isset($_POST[‘inlineposts_update’]))
{
check_admin_referer();// Update title tag
$titleTag = $_POST[‘inlineposts_title_tag’];
if ($titleTag == ”) $titleTag = ‘h2’;
update_option(inlineposts_title_tag, $titleTag);// echo message updated
echo “<div class=’updated fade’><p>Inline Posts options updated.</p></div>”;
}?>
<div class=”wrap”>
<h2>Inline Posts Options</h2><form method=”post”>
<fieldset class=’options’>
<table class=”editform” cellspacing=”2″ cellpadding=”5″ width=”100%”>
<tr>
<th width=”30%” valign=”top” style=”padding-top: 10px;”>
<label for=”inlineposts_title_tag”>Title tag:</label>
</th>
<td>
<input type=’text’ size=’16’ maxlength=’30’ name=’inlineposts_title_tag’ id=’inlineposts_title_tag’ value='<?= get_option(‘inlineposts_title_tag’); ?>’ />
The tag you want the titles of posts to appear in.
</td>
</tr>
<tr>
<td colspan=”2″>
<p class=”submit”><input type=’submit’ name=’inlineposts_update’ value=’Update Options’ /></p>
</td>
</tr>
</table>
</fieldset>
</form>
</div>
<?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 = ‘- ‘;
$numMatches = count($matches[0]);
for ($i = 0; $i < $numMatches; $i++)
{
$titleTag = get_option(‘inlineposts_title_tag’);$postId = $matches[0][$i];
$post = get_post($postId);$linkToPost = ‘‘;
$postTitle = $post->post_title;
// Update the table of contents
$tableOfContents .= ‘- ‘.$postTitle.’
‘;
$postTitleText = “<$titleTag>$linkToPost$postTitle$anchorTag</$titleTag>”;
$postBodyText = ‘<p>’.format_to_post($post->post_content).'</p>’;
$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 .= ‘
‘;// Add top anchor
$content = ‘<p id=”top” />’.$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);?>
- The topic ‘Inline Posts is making all post text a link!’ is closed to new replies.