Jump to content
Sign in to follow this  
jankowalski

front page with cpt

Recommended Posts

jankowalski

i have included custom post types to display on my home page by this function function my_get_posts( $query ) { if ( ( is_home() && $query->is_main_query() ) || is_feed() ) $query->set( 'post_type', array( 'post', 'videos', books', 'movies' ) ); return $query; Now i can display my books by mysite.com/books mysite/videos mysite/movies however i d like to display also just posts, how?

Share this post


Link to post
Share on other sites
jankowalski
yes. but i have set in wordpress settings to show on main page posts including custom post types. so exactly i want to be able to display now "just" post on separate page.

Share this post


Link to post
Share on other sites
Simon
On the separate page use the is_page() condition. like[code]function my_get_posts( $query ) { if ( is_page( 'not-here' ) ) return $query; if ( ( is_home() && $query->is_main_query() ) || is_feed() ) $query->set( 'post_type', array( 'post', 'videos', books', 'movies' ) ); return $query; }[/code]

Share this post


Link to post
Share on other sites
jankowalski
do you mean in template, or just paste it to visual editor on new page?

Share this post


Link to post
Share on other sites
Simon
no use it in your function

Share this post


Link to post
Share on other sites
jankowalski
as i mention in my first post i do use this function, [code]function my_get_posts( $query ) { if ( ( is_home() && $query->is_main_query() ) || is_feed() ) $query->set( 'post_type', array( 'post', 'videos', books', 'movies' ) ); return $query;[/code] is what you suggest diferent from mine? it is the same function. could you re-read my post and get idea what am I trying to do? listing all custom post types in a loop is already done by function, now i am trying to display only posts without cpt which is dificult task now i can display MAIN SITE mysite.com for posts +cpt CPT SITES mysite.com/books for books mysite/videos for videos mysite/movies for movies POST SITE (not working) mysite.COM/posts for posts...

Share this post


Link to post
Share on other sites
Simon
Mine has this added: [code]if ( is_page( 'not-here' ) ) return $query;[/code] Which basically says if were on page 'not-here' then just return the $query.

Share this post


Link to post
Share on other sites
jankowalski
ok, done in child theme. HOMEPAGE loop is fine and is showing both posts and custom post types. But i still don t know how to display only posts loop? mysite.com/posts give 404 error.

Share this post


Link to post
Share on other sites
jankowalski
can you please help?

Share this post


Link to post
Share on other sites
jankowalski
Ok, i think the clue is the line [code]if ( ( is_home() && $query->is_main_query() ) || is_feed() )[/code] so i just want to include those cpt in home loop but not in is_main_query, does it make sense? so i modyfied it to: [code]if ( is_home() )[/code] but i get error and blank page.

Share this post


Link to post
Share on other sites
jankowalski
Come on this is a support forum, you are writing as if we all were programers. Some people need more atention. I m trying my best and still can t solve it. maybe thoe lines would be helpfull for somebody else, but i have no idea what to do with that, can t you be more specific?

Share this post


Link to post
Share on other sites
Simon
Please post all your custom PHP not just bits and bobs, i might be able to see what your doing then. And yes, it is a support forum, not a 24h php support hotline, we do sleep ;)

Share this post


Link to post
Share on other sites
jankowalski
As i said. On clean pagelines system added in function.php [code]function my_get_posts( $query ) { if ( is_page( 'not-here' ) ) return $query; if ( ( is_home() && $query->is_main_query() ) || is_feed() ) $query->set( 'post_type', array( 'post', 'videos', books', 'movies' ) ); return $query; }[/code] I want to know how to display only blog posts loop? I can not be more clear. In wordpress settings/reading i marked first option to display latest posts on homepage (the one which is now modified by function and includes now books and videos entries) So it s working great, no problems about it. On my homepage i have both blog and movies, books etc. The only thing i am trying to do now, is to call the same or actually a new page (template? loop? archives page?) but without cpt. So i need to list JUST BLOG ENTRIES, no videos, no movies. This loop i d like to add as a separate menu item. I hope you got the idea this time. Thank you Simon. I am using pagelines 2.1.6

Share this post


Link to post
Share on other sites
Rob
Jan, First, let me point out that Simon is correct, this isn't a 24 hour instant support forum. I know you'd like to get answers immediately, but that's just not how forum support works. Please be patient with our replies. Additionally, he normally doesn't handle support topics but generously intervened here with the correct code. Moderators are not PHP coders or developers, so we're unable to support most customizations, which is why PageLines offers Pros you can hire for special projects. If you need additional help with this, I'd strongly recommend visiting http://www.pagelines.com/pros and seeking a quote. Please note we do not support customizations if they break the code.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
jankowalski
oh rangelone.. again comenting my topic. very productive and helpfull as always... if there was a single topic you solved out for me? you should get weekly karma as the most usless person on this forum. hope i can continue my conversation with @simon now without your interruptions.

Share this post


Link to post
Share on other sites
Simon
Just for your information, weekly karma is NOT calculated on how many posts you answer, or create, in fact you could answer 1000 posts and still not get any 'karma'. Even I found your reply to one of our staff quite rude. Constantly rejecting answers is getting tiresome also, they stay open and in the support queue until you click accept. So anyway, back to your code, as I started to help you I might as well finish it. The code you added to functions.php is either incomplete or you have other code elsewhere that uses it, as functions will never execute unless called. So how are you using this code? I'll be back tomorrow, I dont work on Sundays.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×