Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialS K
Courses Plus Student 3,106 PointsCross-posting in Wordpress
Hi,
How would i be able to create cross-posting abiltiy in wordpress, say I am owner of post y and but I wish to display post x in my webpage too, say for instance just using post x's url.
S
4 Answers
Matt Campbell
9,767 PointsAre these posts all from the same site? WordPress does not discriminate between who owns the post unless you tell it to. So, everyone's posts will display on a page with a basic loop asking to get all recent posts.
S K
Courses Plus Student 3,106 Pointsno..it is some sort of plugin addition. You cannot add the other users post,but have the ability to add thier post on your blogpage. Say we will have something in the admin page, an option filed probably, where we can just enter the url of the other users blog post, and this function will append their posts to our page.
Matt Campbell
9,767 PointsOk, I see what you're getting at. You want to be able to take other users' posts and add them to a page? I've given this 30 seconds though as I'm about to call it a night but here's what I think you're going to need to do.
You'll need to create input boxes obviously, those input boxes will save data to an array. The same array as the WP_Query function would which, when saved to WordPress will use this array to create a loop with said saved data. It's not going to be easy, I can tell you that.
Another option would be to include the page via PHP or something and then somehow remove everything from the source code except the loop. I have no idea how I'd go about this option though. lol.
Without sitting down and doing it, I can't be of much assistance I'm afraid as, like I said, I've given it all of a few minutes thought.
Zac Gordon
Treehouse Guest TeacherWould using related posts and then customizing the template to append the content from the related posts work?
S K
Courses Plus Student 3,106 PointsHey Zac,
First of all your videos were amazing. Thank you. My scenario is say i have table wp_1_post (blog id =1), and wp_2_post, my goal was to pull out all one post from one blog and attach it to another. I had to do posts, and posts meta separately. Everything went well, but I was stuck with the tags and the category. The problem is in the blog where it is posted, the slug name appears but not the name, i wish it to display. Here is my code:
$categories = get_the_category($post_ID); $tags = wp_get_post_tags($post_ID);
$cats = array();
foreach ($categories as $category){
$cats[] = $category->name ;
}
$tagx = array();
foreach ($tags as $tag){
$tagx[] = $tag->name ;
}
wp_set_object_terms($post_id_new, $cats, "category");
wp_set_object_terms($post_id_new, $tagx, "post_tag");.
Let me know if there is an email, i can share the remaining code with you, for a clarity check.
Shamim
Zac Gordon
Treehouse Guest TeacherI don't see where you're pulling in the get_category_link(). Shouldn't that be in there. Or at least pulling in the category slug and you can recreate the URL?
S K
Courses Plus Student 3,106 PointsS K
Courses Plus Student 3,106 Pointssay we have a blogging website, managing the content of various journalists. i want to give them an exta field which will allow user a to append an article of another user.
Matt Campbell
9,767 PointsMatt Campbell
9,767 PointsSo you want users to be able to edit and add to other users' posts?
Just set the user permissions of said user to be able to edit posts. Editor should do it.