fetch registered user posts in wordpress - wordpress

I am making a wordpress website on which the main posts are coming on the homepage .
I want that if a user regiters on the website and if he make posts on the website , his/her post should go on a a specific page rather than coming on the homepage where the main admin posts are coming .
how to fetch the registered user posts to a specific page .
Please help if anyone can .
Thanks in advance

You can try specifying the author ID. For content-home.php page use
$posts = get_posts('author=1&posts_per_page=1&orderby=date&order=desc');
$post = $posts[0];
If you want to show only the latest post.
And for the other page exclude this ID.
$posts = get_posts('author=-1');

Related

Change wordpress blog limit to months rather than by number of posts

Is there a way to override how wordpress displays a number of posts on a listing of posts page, regardless of page type (archive, category, posts, tags etc.)?
I'm transferring content from a static site where the pages are saved using a month format.
I'd like to be able to set wordpress' previous/next link navigation to work using months, rather than the limit of posts per page.
So if the navigation would go forward/backward to the previous/next month where there is published content.
Thanks
Perhaps a WordPress Query will work?
Such as... (Not tested)
$month = date('m');
$query = new WP_Query( 'monthnum=' . $month );
As the WordPress Codex lists

Wordpress permalink from the database?

I am trying to access selected post information from my WordPress database to display on a second website which is not a WordPress site nor is it php, it is in fact an asp.net website that i want to display the information on.
I have a WordPress blog at blog.domain.com and another website at domain.com both running on different servers and I need to display the excerpt, title with link on my asp.net website for selected posts. I can easily grab the excerpt and title from the blog's database but the only problem is that the permalink is not in the database.
I had the idea that maybe if I place a short piece of code on every blog to insert the permalink to a new table, i could then grab that to use over on the other website. But that didnt work, perhaps I am not doing it right. This is the code I used;
<?php
global $wpdb;
$table_name = $wpdb->prefix . "posts_pages_url";
$wpdb->insert($table_name , array('post_id' => the_ID(), 'url' => the_permalink()));
?>
Some might say, "why dont you just use an RSS Feed?" Well if it comes down to it, I just might have to, but i would prefer not to as connecting to the database directly to access my selected posts is much more flexible.
I would be very grateful if anyone had any suggestions on how I can access the permalink via a database call.
Many thanks
You could use get_permalink() in your code, or link to the guid value in the DB - not ideal I know, but it should at least work.
EDIT:
Same goes for the_ID() - it should be changed to get_the_ID().
This code will get it for you if using Yoast
$q = "SELECT * FROM wp_yoast_indexable yi
WHERE object_type = 'post'
AND object_id = '$ref'";
$yis = $scDb->select($q);
$permaLink = "";
if(isset($yis[0]))
{
$permaLink = $yis[0]->permalink;
}

Wordpress . How to move some post from front page to a different page?

I have 40 or so post on a WordPress site.
I need to move about 20 of them to a new page I created.
I have created to (New) page and a new category for these post.
I changed edit some of the post and changed the category to the new one.
They show up on the (New) page , but they all so show up on the Front page as well.
What needs to be done to get the post to just show up on the (New) page and not the Main page of the site.
Thanks for your help.
Exclude that category from the front page like so:
if ( is_front_page() ) { query_posts( 'cat=-1' ); }
Switch out the "1" with the ID of the category you want to exclude. The - sign in front of the ID says it is excluded.
Reference: WordPress Codex: Query Posts

wordpress: want to show only admin posts on home page

Suppose i have a blog where lots of people post their post under different category. But i want to show only those post on home page which are posted by a admin. Rest of the author post will be shown under specific users pages.
So is there any plugins available for this? or any code that might help me to fullfil my purpose.
$query = new WP_Query( 'author=1' );
userid 1 is always admin, if you havent changed it, if you have multiple admins please have it : $query = new WP_Query( 'author=2,6,17,38' );
You can read more about it here: http://codex.wordpress.org/Class_Reference/WP_Query
Good luck!
Marten

Allow only certains user posts to display on a page in Wordpress?

I have two special users on my site. Let's call them user1 and user2. User 1 manages "user page 1" and user2 manages "user page 2". I want their posts to appear when I click on these links and only see their posts in Wordpress.
Should I use categories for this and if so, how do I create a link to only show posts from a certain category?
Do I need a module for this?
If the answer is still not clear, how do I do this?
You can use wp_qurey() function to show posts from specific authors.
Display posts by author, using author id:
$query = new WP_Query( 'author=123' );
Display posts by author, using author 'user_nicename':
$query = new WP_Query( 'author_name=rami' );
More details here - http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
You can use the get_author_posts_url() to create a link to a page listing a specific author's posts: http://codex.wordpress.org/Function_Reference/get_author_posts_url
The format of the link (if you just want to go ahead and test it in your browser first) will be http://www.yoursite.com/author/authorname.
Hope that helps!
Copy your index page loop and then change query from post_per_page query to this and you're done.
$query = new WP_Query( 'author_name=rami' );

Resources