{"id":2358,"date":"2023-04-27T23:19:23","date_gmt":"2023-04-27T21:19:23","guid":{"rendered":"https:\/\/www.molongui.com\/help\/?p=2358"},"modified":"2023-04-27T23:24:05","modified_gmt":"2023-04-27T21:24:05","slug":"how-to-modify-author-posts-template","status":"publish","type":"post","link":"https:\/\/www.molongui.com\/help\/how-to-modify-author-posts-template\/","title":{"rendered":"How to modify author posts template"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2358\" class=\"elementor elementor-2358\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3527bcee elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3527bcee\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7972c03d\" data-id=\"7972c03d\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b8537eb elementor-widget elementor-widget-text-editor\" data-id=\"b8537eb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<a href=\"\/authorship\/\" target=\"_blank\" rel=\"noopener\">Molongui Authorship Pro<\/a> allows you easily display a <a href=\"\/help\/how-to-display-a-list-of-posts-by-author\/\" target=\"_blank\" rel=\"noopener\">list of posts by author<\/a>. And you have different layouts to choose from. However, you might want to display the list in a very different way.\n\nIf you find yourself in such need and you have PHP coding skills, keep reading because this article is for you.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d3cd63f elementor-widget elementor-widget-text-editor\" data-id=\"d3cd63f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>There is a convenient hook you can use to provide your very own template. The <code>authorship_pro\/author_posts\/template<\/code> filter.<\/p>\n<p>It filters the <strong>full path<\/strong> to the template to load. So you can overwrite the default one like this:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5fb63de elementor-widget elementor-widget-code-highlight\" data-id=\"5fb63de\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp>add_filter( 'authorship_pro\/author_posts\/template', 'my_author_posts_template' );\nfunction my_author_posts_template()\n{\n   return '\/var\/www\/wordpress\/wp-content\/themes\/my-child-theme\/templates\/molongui-author-posts.php';\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0b7a29e elementor-widget elementor-widget-text-editor\" data-id=\"0b7a29e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>So your hooked function must return the <strong>full path<\/strong> to your custom template. Obviously, returned value in the code above is just an example.<\/p>\n<p>And which data do you have available? Basically, you have the <code>$posts<\/code> variable, which is an array of <code>WP_Post<\/code> objects and the <code>$author<\/code> class. But you better check out any of the default templates packaged with the plugin. You will find them as .PHP files in the <code>wp-content\/plugins\/<wbr \/>molongui-authorship-pro\/views\/<wbr \/>posts-list\/<\/code> folder.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Molongui Authorship Pro allows you easily display a list of posts by author. And you have different layouts to choose from. However, you might want to display the list in a very different way. If you find yourself in such need and you have PHP coding skills, keep reading because this article is for you. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,45],"tags":[58,12,19],"class_list":["post-2358","post","type-post","status-publish","format-standard","hentry","category-authorship","category-howto","tag-author-posts","tag-howto","tag-shortcodes"],"_links":{"self":[{"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/posts\/2358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/comments?post=2358"}],"version-history":[{"count":7,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/posts\/2358\/revisions"}],"predecessor-version":[{"id":2365,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/posts\/2358\/revisions\/2365"}],"wp:attachment":[{"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/media?parent=2358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/categories?post=2358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.molongui.com\/help\/wp-json\/wp\/v2\/tags?post=2358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}