is there anyway to send notification of new Post is published in wordpress to another page of same website? - wordpress

I'm creating a wordpress plugin in which i want that if new post is published the notification gone on another page of same wordpress website.
Thanks

There is a few ways todo this. But I would do it this way.
When you create a post, you add a post_meta to that post that tells that this page is new.
Then you have an cronjob or something that is running an wp_query that are searching for all posts that have that post_meta. And when it finds the new post/posts it either clear that post_meta or set it to false.
And then on the page that you wanted to display it somehow, use that cronwork to update that page or something like it.
Hard to describe more when I don't know what that other page should do with the information about the new post

Related

Creating user profile pages in wordpress

What I'm trying to achieve is to make each user on the website(the wp-users) have their own unique front-end profile pages like so site.com/user/userX. (EDIT: To clarify, it is not a settings page that only the user himself can see, it's a open profile page for logged users or anonymous/visitors to access and see its profile)
I thought about using the url GET (site.com/user?name=userX) in a post but wordpress doesn't seems to understand "?..=.." and says page doesn't exist. This solution does not look like a good practice in wordpress so I'm trying to look from another perspective.
Even tho there are a couple of plugins there that would do that for me and more, I'm stuck with doing manually since I'm building a multi-language website (using Polylang), so plugins will only work in the main language.
Briefly, Polylang keeps track of the language through url, ex.: site.com/langX/pageX, and the plugins I've tried are stuck to one page only.
I'm inclined to say what I'm looking for is a way in the functions.php to make Wordpress understand that a page .../user/ will expect a name right after .../user/userX like that I can use the same function for multiple languages : ...langX/user/userX, ...langY/user/userX ...
I'd be glad if someone could put me in the right direction of what should I be looking for.
for security you should create a new route in wordpress :
function custom_rewrite_basic() {
add_rewrite_rule('^user/([0-9]+)/?', 'index.php?user_profile=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');
function custom_rewrite_tag() {
add_rewrite_tag('%user_profile%', '([^&]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
Now, you can access the same page as :
http://example.com/user/95
this code in your theme :
get_header();
global $wp_query;
if($wp_query->query_vars['user_profile']) {
//do stuff
}
From my understanding, what you can try is to create a page from dashboard, named user or something. Once users are logged in, you can get user info in session or you can use the query vars as you mentioned above. You can create custom page templates in Wordpress and assign that template to the page. In this page template write the frontend html-s with required logic. Routing in WordPress is normally handled by WordPress itself. So creating a page will make that route say yoursite.com/user available for you. Please read on page templates from the below link from WordPress documentation.
https://developer.wordpress.org/themes/template-files-section/page-template-files/
UPDATED ANSWER
As per the comments
Create a custom post type which holds the data(users)
When a user registers, create the entry for users post type, link user id to that post type entry with a post meta. You can set a unique url for the user by setting the slug as you need.
Provide users the ability to edit only their own data. You can check the post meta which connects user id with that particular custom post type item.
If a user gets removed, delete their custom post type entry as well, so that nothing remains in the DB related to the user.

Wordpress new post

on a default wordpress installation, what actually happens when you click publish?
I know there's a new entry added to the posts table, but what else happens - Is there anything else updated such as tables, automatically telling search engines about them, updating sitemaps etc?
Sorry if this is the wrong sort of question to ask!
save_post action is triggered whenever a post is created or updated, it means that any code inside core, themes, or plugins that is hooked with that action is launched.
Well, if you have google XML sitemap, a new entry makes changes in your sitemap xml file and during google bot's next visit, your xml file automatically tells google about the new post you added. Something like this.

Need to clone a existing wordpress admin page

I need to create a new page which will have same functionality of one the page of admin.
I have a page which is accessed by /wp-admin/post-new.php?post_type=shop_order.
I have made a copy of this page by the name "new-post0.php" but when I access new cloned page , its content is different!
I m missing something at registering this new page?
You shouldn't copy and paste Wordpress core files. That's called "hacking the core" which is very very bad.
http://websynthesis.com/dont-hack-wordpress-core/
You should instead develop your "new-post" page as a new custom post type.
You can learn about them here:
http://codex.wordpress.org/Post_Types
The link /wp-admin/post-new.php?post_type=shop_order you posted refers to a new post page for a custom post type.
To get another page like that, you'll need to create another custom post type and add the custom meta fields.
If you can't code it, there are plugins that you can use to achieve the same results.
Custom Post Type UI to create custom post types and ACF for custom fields. Right now, you should download ACF from Github.

Adding custom user options to wordpress

I am trying to add a custom field to the wordpress user profile page. For instance if I wanted to add a field where the user could put in their Linkedin, or Twitter user name, then use that value whenever the user posts a comment, or if the user is an author, to add that value in their posts.
I have a forum (bbpress) integrated so I would also like to use this value to customize the users avatar in the forums.
I am looking at the way Wordpress uses Gravatar. I would like to do something similar. However, I'm not sure where to start. I've written a couple of shortcode plugins in the past, but nothing this complicated.
Anyone have any ideas on where I should begin on this?
look at this post and this

wordpress custom post type

So I've just made a custom post type for my wordpress theme named "Products". When I create a new post in it and view it, the link is something like this:
"http://localhost/wordpress/product/a-product-title"
This page views as expected but when I try to go to the supposed parent page:
"http://localhost/wordpress/product/"
I get a 404 error page. Is there a special template I need to make to view this page?
Thanks
I found what to do. I just created a new page called "Products" and set it as the posts page. Then I put this in front of the loop
$wp_query = new WP_Query("post_type=product");
and it worked
I had the same issue - I think it's down to the fact that right now, WP 3.0 simply does not behave as you would expect with custom post type 'archives'.
Check out Smarter Custom Posts to easily build-in this behaviour.
The name Products is also used by Woocommerce so be aware that if you install this too, the custom post type will stop working.

Resources