WordPress.org

Ready to get started?Download WordPress

Forums

ELI's Related Posts Footer Links and Widget
[resolved] How to call function directly in single.php, without using filter? (8 posts)

  1. kyool
    Member
    Posted 1 year ago #

    Is there any way to call the function directly in the single.php, instead of using the content filter?

    I would rather this info not show up as part of the actual content of the post, but afterwards. I am doing some pagination printing and printing of share links in the single.php and want the related posts to appear after all of that. Also, I have noticed for really short posts, this related posts info gets put into the excerpt.

    http://wordpress.org/extend/plugins/spostarbust/

  2. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    I understand you need. Here is what I would suggest you try:

    <?php
    $SPOSTARBUST_widget = true;
    SPOSTARBUST_init();
    unset($_eli_debug_microtime['SPOSTARBUST_init_skip']);
    echo SPOSTARBUST_related_links_on_posts("");
    ?>

    Be sure to try this with “Automatically add links to Related Posts at the bottom of every Post?” turned off in the settings.

    Please let me know how this works for you.

    Aloha, Eli

  3. kyool
    Member
    Posted 1 year ago #

    Hmm, I checked the No option and saved the settings and then tried the following:

    if( function_exists('SPOSTARBUST_related_links_on_posts')) {
    $SPOSTARBUST_widget = true;
    SPOSTARBUST_init();
    unset($_eli_debug_microtime['SPOSTARBUST_init_skip']);
    echo SPOSTARBUST_related_links_on_posts("\n \n");
    }

    but I was seeing it twice now--once in the content and once afterwards.

    So I edited the code and //'d out the two add_filter calls and it looks like it's working correctly now.

    Thanks.

  4. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the update. I'll mark this topic resolved for now. Your's is the 2nd request for theme integration so I am thinking of adding a quick-and-easy drop-in-your-theme function in a future release. Please let me know if you find anything else that may help.

    Aloha, Eli

  5. kyool
    Member
    Posted 1 year ago #

    I spoke too soon--looks like this causes the post to displayed twice--it starts all over again after the Recent Posts box.

  6. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    So the Recent Post box is resetting the page query or something?

    Can you send me a link to the misbehaving page so I can check it out?

  7. kyool
    Member
    Posted 1 year ago #

    OK, so here's the latest, which seems to work:

    I left the settings set to

    yes (Use this setting and you don't need the Widget)

    In my single.php I added:

    <?php
    if( function_exists('SPOSTARBUST_related_links_on_posts')) {
        $SPOSTARBUST_widget = true;
        SPOSTARBUST_init();
        unset($_eli_debug_microtime['SPOSTARBUST_init_skip']);
        echo SPOSTARBUST_related_links_on_posts("\n \n");
    }
    ?>

    And in the index.php for the plugin, I commented out lines 318 and 610, which did:
    /add_filter('the_content', $SPOSTARBUST_plugin_dir.'_related_links_on_posts');

  8. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    Cool kyool,
    Thanks for the update. I'll test that method out in a new function wrapper and use it on one or two of my custom Themes. If it works good for me then I'll put it in my next release.

    Aloha, Eli

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.