Support » Plugin: Random Post Plugin - Redirect URL to Post » Keeps showing the same post

  • Resolved supervinnie40

    (@supervinnie40)


    Hi there,

    Thank you for the plugin.

    As per your guide, I put /?redirect_to=random on the end of the URL in mijn menu. But I keep going to post #1.
    If only have 10 posts right now, with 5 categories, but each time I click the link I keep going to post #1.

    It kinda seems the plugin isn’t working for me.

    I deactivated all the plugins and tried to change theme, with no effect.

    https://wordpress.org/plugins/redirect-url-to-post/

Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter supervinnie40

    (@supervinnie40)

    Yes its free, but I don’t know if the author is still very active. Last theme update was 5 months ago I believe.
    I’ll sent him a link to this topic.

    Plugin Author Christoph

    (@camthor)

    You could also search the code of the theme if it modifies somewhere the query, e.g. search for “posts_orderby”. Maybe it is used for a feature that you don’t need anyway.

    Thread Starter supervinnie40

    (@supervinnie40)

    No luck on that last code 🙁

    Thread Starter supervinnie40

    (@supervinnie40)

    No luck with that last bit of code 🙁

    Also tried to search all files with Notepad++ for “posts_orderby”, and it can’t find it anywhere.

    Plugin Author Christoph

    (@camthor)

    Just found:

    To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

    https://codex.wordpress.org/Function_Reference/remove_filter

    So if you discover the priority when the filter was added (if it was added), you could try the same value in the remove_filter.
    (Or, better, since the theme doesn’t get updated anymore, remove the priority in the theme where the filter is added.)

    Plugin Author Christoph

    (@camthor)

    Can you post a link to where to get the theme?

    Thread Starter supervinnie40

    (@supervinnie40)

    https://wordpress.org/themes/wikiwp/

    Edit, just noticed that is was updated recently. Doesn’t really matter, because I only downloaded last week.

    Plugin Author Christoph

    (@camthor)

    In your theme’s function.php, could you please edit the function “wikiwpCustomPostOrder” and comment out

    // $query->query_vars['orderby'] = 'order';

    (l. 214)

    I tried here and it helps. Can you confirm?

    (PS: Possibly have to undo again the changes from the plugin file.)

    Thread Starter supervinnie40

    (@supervinnie40)

    Everything working perfectly with the random plugin!! Great.

    Any chance you know what was wrong with it? And what that bit of code in Functions.php is supossed to do?
    (I’m familiar with PHP, but not that good 😛 )

    Plugin Author Christoph

    (@camthor)

    Woohoo, finally!

    My plugin sends a query to retrieve the posts. The theme has registered a hook to modify every query, no matter what you write in your query.

    I don’t know what it is for (the theme author might know). You could check if anything on your blog is broken. If not, I would create a Child Theme and there put into function.php the modified function:

    // order posts in categories - modified
    add_action('pre_get_posts', 'wikiwpCustomPostOrder');
    
    function wikiwpCustomPostOrder($query) {
    	if( (is_category('news')) ) {
    		$query->query_vars['orderby'] = 'modified';
    		$query->query_vars['order'] = 'DESC';
    	}
    }

    This will override the original function.

    (Without the child theme the changes get lost every time you update your theme.)

    BTW, it seems that the redirect_to will still be broken on that “news” category.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Keeps showing the same post’ is closed to new replies.