Wordpress - How to create a fav posts feature - wordpress

I want my users to be able to mark posts as favorite. I tried the wp-favorite-posts plugin, but it doesn't work. I mark posts as favorites and after refreshing the page it's all gone. Furthermore, if I put {{wp-favorite-posts}} to a page, it just shows the text.
So I want to create my own solution, but don't really know how. I have never edited the WP database, but I have plenty of PHP mySQL experience.
Can anyone please point me in the right direction ?

You can use post_meta. You can store the "favourite" aspect as a custom field attached to each post. You don't need to manually edit the database (i.e. via mySQL).
When you want to show the favourited posts, run a custom query that only shows posts with the specific custom field that you've specified.

Related

Wordpress ACF fields disappeared

I have been working with wp for a while now but just ran into a bug, that I can not fix with the information found in the internet.
I was editing a acf field. When I was finished writing into one of the fields, I mistakenly pressed enter. The page started reloading and all fields were gone. When going to the frontend, everything is displayed properly.
I tried to reactivate my ACF fields via the screen options what did not work. I inserted some code lines into my functions.php. or into the input.css because I thought maybe the right checkbox for the ACF fields to be displayed was missing. Nothing helped. Is there any other way to fix this issue.
thx in advance
greetings
I just come through this problem : for one of my field group, the fields box just disappeared at some point and I had no way no retrieve it thanks to the Wordpress Admin interface.
I don't know the reason why, but it appears that in my case, ACF registered some "unwanted" user meta in my database. (how is the question)
If you look inside your DB at the usermeta table content you will probably find some ACF entries like : metaboxhidden_acf-field-group or closedpostboxes_acf-field-group and maybe others...
The one causing trouble for me was meta-box-order_acf-field-group : I simply deleted the entry (but you can try editing it to remove the reference of your "lost" box) and the problem was solved.
Maybe too late to help you, but hope it can still help someone !
##EDIT##
Seems I may have a clue about how the box disappeared
Steps to reproduce :
Create a field group and associate it with whatever post type you have
Go create a whatever post (note : the Gutenberg editor is active on this edit page)
You should find your fields group at the bottom of the page
Try to move the group meta box above the Gutenberg editor (without success because it seems not possible)
Save your post
Come back to the edit page of the field group and refresh it
Tadaaa ! the fields group box is not available anymore
Go to your database, the usermeata table, you will find the entry causing the trouble again : meta-box-order_acf-field-group = a:3:{s:4:"side";s:32:"submitdiv,acf-field-group-fields";s:6:"normal";s:57:"acf-field-group-locations,acf-field-group-options,slugdiv";s:8:"advanced";s:0:"";}
I solved the problem by adding a custom script for the ACF with delete class closed on #acf-field-group-fields:
document.addEventListener("DOMContentLoaded", function(event) {
document.querySelector('#acf-field-group-fields').classList.remove('closed');
});

Within an admin menu point, set number of posts via input field

I'm quite new to Wordpress and currently working on a custom plugin.
I know how to create a new admin menu point via plugin, now I'm trying to figure out how to add a functionality, when entering the site the user shall be able to specify the number of shown posts via input field - the amount of posts shall be saved in a way that you receive a shortcode for the amount.
Hope that was clear. Thanks in advance!
I know there are a lot of Wordpress php codesnippets and shortcuts to use, but I'm uncertain which the ones are I need.

Wordpress custom fields not saved in database

I've been running a WordPress site for over a year now and never had a problem with it until yesterday. I'm using a custom field to store the url to a preview image for every post. I simply add it using the standard Custom Fields form in the Edit Post screen. Before when I'd save the post as a draft or if I immediately published it the custom field would be saved. But now all of a sudden no matter how I save the post (save as draft, publish or auto-save) the custom field isn't being stored in the database. I did confirm this by checking the wp_postmeta table.
I already reinstalled Wordpress, but it doesn't change a thing. I also went through other similar posts about this subject, but none of the solutions work.
Any ideas?
So after digging deeper, I figured out the custom field was dependent on another field. Still not sure why it wouldn't store the custom field in the database even though the other field wasn't filled out first. But it works anyway when I do it that way. WordPress works in mysterious ways sometimes.

User template with recent posts

I'm developing a custom theme for Drupal 7. My problem is I don't know how to make a page that shows information about the author, and below the info, a list of the author's articles. (For ex. if I go to user/ i want to see the profile of the user with the given id, and his/her latest posts).
So what would be the best solution for this?
I've tried with creating user-profile.tpl, it's ok, but I dont' know how the get the nodes, and I don't really want to make sql query-s, because I think there is a prettier method for this.
I've tried with Views, too, but I'm new to Drupal and the most of the tutorials/explanations were for drupal 6 (if it's simple with view, please write me a small guide for it).
Thanks!
It'd be better to create a view that takes the uid as an argument.

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

Resources