php - List all Posts under heading in wp_list_pages menu -


I am currently using default page navigation (wp_list_pages) with WordPress, and I have used my home page as "home" and My blog is called "Events" on one page but I want to list 10 most recent posts under the "Events" child.

I tried to hack it in using the code, but it dropped the content at all places and deleted tags:

  add_filter ('wp_list_pages', 'Add_forum_link'); Function add_forum_link ($ output) {$ output. = '& Lt; Li & gt; & Lt; A href = "#" & gt; Blogs & lt; / A & gt; & Lt; Ul & gt; '; Query_posts ('showposts = 10'); While (is_paus ()) {the_post (); $ Output = '& Lt; Li & gt; & Lt; a href = "'. the_permalink ()." & Gt; 'the_title ().' & Lt; / A & gt; & Lt; / li & gt; '; } $ Output. = '& Lt; / Ul & gt; & Lt; / Li & gt; '; $ Echo output; }   

In addition to this it was included in creating a new link called "Event" and therefore it does not work very well.

Is there a substitute for finding Word, which page has I set as my post and has shown the last 10 blog posts under that headline?

Any help would be great!

try it, use WP_Query instead of query posts,

besides , You can not see the list of entries under a page name (title). Because a post is not related to a page, so either you need to place the page name as a category and list the category of specific category.

  add_filter ('wp_list_pages', 'add_forum_link'); Function add_forum_link ($ output) {$ output. = '& Lt; Li & gt; & Lt; A href = "#" & gt; Blogs & lt; / A & gt; & Lt; Ul & gt; '; $ query = New WP_Query (array ('posts_per_page' = & gt; 10, 'post_type' = & gt; 'post')); While ($ query- & gt; is_paus ()) {$ query- & gt; The_post (); $ Output = '& Lt; Li & gt; & Lt; a href = "'. the_permalink ()." & Gt; 'the_title ().' & Lt; / A & gt; & Lt; / li & gt; '; } $ Output. = '& Lt; / Ul & gt; & Lt; / Li & gt; '; $ Echo output; }   

// Or if u need a list of all the posts under category events, use it, but you have to add the category with the name "Event"

  add_filters ('wp_list_pages', 'add_forum_link'); Function add_forum_link ($ output) {$ output. = '& Lt; Li & gt; & Lt; A href = "#" & gt; Blogs & lt; / A & gt; & Lt; Ul & gt; '; $ query = New WP_Query (array ('posts_per_page' => 10, 'post_type' = & gt; 'post', 'category_name' = & gt; 'events')); While ($ query- & gt; is_paus ()) {$ query- & gt; The_post (); $ Output = '& Lt; Li & gt; & Lt; A href = "'the_permalink ()." & Gt; 'The_title ().' & Lt; / A & gt; & Lt; / li & gt; '; } $ Output. = '& Lt; / Ul & gt; & Lt; / Li & gt; '; $ Echo output; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -