{"id":2045272,"date":"2011-04-22T14:54:08","date_gmt":"2011-04-22T14:54:08","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/function-get_next_post_by_author-modification-1\/"},"modified":"2016-08-19T23:44:03","modified_gmt":"2016-08-19T23:44:03","slug":"function-get_next_post_by_author-modification-1","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/function-get_next_post_by_author-modification-1\/","title":{"rendered":"Function get_next_post_by_author modification"},"content":{"rendered":"<p>Hello. I&#8217;m using this custom function I found here: https:\/\/wordpress.org\/support\/topic\/previous-next-post-navigation-by-author?replies=7<\/p>\n<pre><code>function get_next_post_by_author($link=&quot;%link &amp;raquo;&quot;, $title=&quot;%title&quot;) {\n        global $wpdb, $post;\n        $next = $wpdb-&gt;get_row($wpdb-&gt;prepare(&quot;SELECT ID, post_title FROM $wpdb-&gt;posts WHERE post_type=&#039;post&#039; AND post_status=&#039;publish&#039; AND post_author=&#039;&quot;.$post-&gt;post_author.&quot;&#039; AND post_date &gt; &#039;&quot;.$post-&gt;post_date.&quot;&#039; ORDER BY post_date ASC LIMIT 1;&quot;));\n        if($next) {\n                $title = preg_replace(&#039;\/%title\/&#039;,$next-&gt;post_title, $title);\n                echo preg_replace(&#039;\/%link\/&#039;, &#039;&lt;a href=&quot;&#039;.get_permalink($next-&gt;ID).&#039;&quot; rel=&quot;next&quot;&gt;&#039;.$title.&#039;&lt;\/a&gt;&#039;, $link);\n        }\n}<\/code><\/pre>\n<p>This gets the next post by the same author.<\/p>\n<p>I would like to include the $in_same_cat filter in that function, just like in the normal next_post_link function, but I don&#8217;t know where to put that.<\/p>\n<p>Thanks.<\/p>\n","protected":false},"template":"","class_list":["post-2045272","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2045272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2045272\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=2045272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}