Wordpress | Automatically repost entries to the start page by date - php

I'm looking for a solution to regularly show a post on the startpage. The way to archieve this is to update the last modification date of a post, which can be easily done using an SQL statement. Alas this skips the regular Wordpress update hooks such as "post new entries to twitter".
So I'm looking for a PHP cronjob script to "emulate" the user updating the modification date of a post and clicking the publish button.
How can I do this? Adding wp_load.php to my script and then ... ?
Thanks for advice,
Johannes

You can't use the "Stick this post to the front page" function under "Visibilty" in the "Publish" section of the post editor? And then use your Twitter plugin posting options to retweet when the post is edited?

You can modify your template/theme file to show specific posts or almost anything else...
All you need to know is a little PHP and browse the WordPress Codex
Check out query_posts():
http://codex.wordpress.org/Function_Reference/query_posts

Thanks for your responses so far, but I'm not sure if I described my goals correctly. I don't want to stick posts, I need a feature similar to the Unix "touch" - modify a post's creation date to NOW and (in the case of wordpress) execute all new post handlers such as post to twitter.
query_posts is indeed a useful function to style the startpage, but it doesn't go far enough in my case.

What is this startpage?
I can only think of a Homepage in your case, and as you have stated before, You could include wp-load.php and then create the loop.
If you are trying to grab the latest post in your wordpress blog and update the date to today's current date, you will probably need to do a query in the wordpress database.
$wpdb->query("UPDATE wp_post SET post_date = date WHERE id = id");
The above query will need some modification. From there you can put that in a cronjob.

Related

How to Store Permalink to Post Authored by User in His Meta Data - WordPress

Here is the situation.
I have a custom post type, let's call it "Listings." I have numerous authors, each of whom has exactly one post of type "Listings." No more, no less.
I want a custom field, let's call it "listing_link", where the link to each author's "Listings" post is stored. I would like this to be generated automatically.
So essentially I need some kind of function that will:
1. Cycle through each author
2. Find all posts of type "Listings" by that author
3. Get the permalink to the first (and only) post of that type by that author
4. Finally save that link in a custom field I've created
I could code bits of this, but I'm really not sure where to start. When/how would this function run? How would it refresh? How do you actually save it to their meta data?
Any help would be appreciated, even if it's not a full script. I really just need to be sent in the right direction! If I can come up with a functioning solution, I will share it with the community!
Do you have to store 'listing-link'? Why not just query "listings" when you need the information?

How to load records in real time using PHP & jQuery?

I have created a system using php from which we can add Status messages or you can say a kind of Microblog. So it has a database table like below :
posts_mst
------------------
post_id_pk
post_title
post_content
date_added
Now I have displayed all these posts on a page using select Query and it is displaying all the posts on a single page nicely. But now I have extended the page functionality and added a form to add these posts from same page. So that form stands on the very top of the page, and below it all the posts are getting listed.
I am storing all the posts using jquery .ajax() method so page do not load while saving any post. So now what I want to do is, when I add any posts, it should keep adding the same posts on the list in a real time, like you see in a Facebook - when someone posts on their wall, we see it loaded on the spot on our News feed. Here I want to do the same, as this page will be used by so may people and posts are displayed to everyone.
There is one way I can do this is - I can append a Div tag to the list of posts everytime a New post is added. This Div content I can get using Ajax response. But that will work for only My added post. If someone else adds the Post, I will not be knowing that.
So can anyone suggest me how I can implement this ? If there is any specific plugin used for that then let me know. :)
Thank you
The easiest way is to use a javascript setTimeout every X minutes / seconds and use ajax in the timeout function to check for new posts. You can track of what's new by storing a timestamp of the latest update in a session for example.
Note that this is periodic polling, it is not really realtime.
There are newer ways to maintain a permanent connection to the server, but that's a whole other story.

Update a record with a single click

I am working on a CMS for a website using PHP and MySQL and have been asked if it is possible to 'publish' articles just by clicking on a button?
To make things clear, the articles may have already been entered into the database but not identified as being ready for publication. Articles for the site have a column in the db called _'pub'_, which is an ENUM('n','y'). I have created a page which lists all articles by section, article heading, date and published.
If _'pub'_ is 'y', published displays YES, otherwise it displays NO
I have created an additional page that changes the state of _'pub'_ so that it works by clicking on the Yes or No for published, but wondered if there was a way of changing the status of _'pub'_ using javascript rather than an additional page.
I look forward to hearing any suggestions
Just use jquery like this
$.post("/submit.php","title='Title of post'&content='PostContent'", function(d){
$(".output").html(d);
});
What that basically does is, sends the content to submit.php with ($_POST['title'] and $_POST['content']).. and then returns the output in a div with the classname output
And everything happens with a single click on the same page
You want the users to stay on same page, is that it?
Use ajax/jQ to:
submit articleid that should be published
on request-completion, change image/text in list from "no" to "yes"
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
is a good start.
regards,
//t

Recommendation for a Pagination procedure AJAX PHP

I am not sure the correct terminology for the process that I am trying to describe. I don't even know which platform is underlying the technique. If you understand my description, please give the link to the site(s) and or the keyword name of the process. I think it is done by AJAX, but I am not certain. I use php as the backend code, I just need to find a way to dynamically display the results. Please give suggestions. I forgot the name of the sites that use this, and my link history expired.
TIA
Description:
The page would have a search form and options. After the user submits, the search is initiated, and the results appear inside the dedicated result area. The page does not refresh, just the info inside the result area.
The display area will show 20 (or whatever) results (lines). There will be next, and previous buttons. If you hit next, the next set of results will display.
I am writing a code that generates 20 results for each display. There is no set number of results, so the results might have a start/first page, but do not have an end page.
Each time the user hits 'next', the program would generate/load new results. It would also store previous results, so that when a user hits 'prev', the previous results can instantly come up.
What techniques/program are theses?
Having recently handled pagination with Code Igniter (php framework), the following links might help you and anyone else out:
http://tympanus.net/jPaginate/
http://codeigniter.com/forums/viewthread/93045/
Usability is important and AJAX pagination introduces some important questions that need addressing regarding pagination, the following article will give some usability guidelines for displaying results in a table:
http://thedesignvanguard.com/crud-r-for-read
Code Igniter Prototype Framework Ajax Pagination:
http://codeigniter.com/wiki/AJAX_Pagination_with_CI_Pagination_Library/
Since we're using jQuery, we chose the following, Codeigniter jQuery framework for AJAX pagination
http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/
http://tohin.wordpress.com/2008/10/07/codeigniter-ajax-pagination-exampleguideline/
It is not AJAX for sure.
Nobody uses AJAX for the pagination.
And there are about zillion pagination examples over internet
The only thing is never described in articles is how to persist search options for the other pages.
But it's simple enough: http_build_query() can help you
You need to have a GET/POST form submitted via AJAX which contains the fields in the search term and page number.
If you are going to set the page size to 20 results, page_num=4 will show results from 61-80 results.
Usually search results are GET instead of POST (Ex: See Google search results ) along with the page_number as another attribute and value.
#IVAN .. good to know that the library came helpful..
About that searching option; check the recent commit in github
http://github.com/neotohin/CodeIgniter-Ajax-pagination-Library there is an additional parameter added for searching.
I think the simple code in readme is enough for understanding the mechanism.
You could use datatables
https://datatables.net/
https://datatables.net/examples/data_sources/server_side.html
With this plugin using jquery also you could use server sided page request , you just have to handle the plugin post using Ajax.
post automatically sends row , page offset column, search criteria you just have to provide the json encode return
and the plugin automatically has library in featuring pagination, search sort number of rows per page and the table formatting.
Needed are jquery, and the plugin css and js for this to work
let me know if you understood my explanation.
thanks (=

How can I pass variables from a form within the Wordpress platform?

I'm building a website using Wordpress. The WP-Events plugin is being used to display a list of upcoming events. What I need is for people to be able to confirm their attendance at any particular event.
WP-Events is a bit awkward in that it's customised using a template that is only able to be edited with the Wordpress admin. I used this template in combination with the Wordpress 'Loop' to generate a form for each event that could be filled in and submitted. I then was going to use jquery to toggle the display of each form as to not make the page massive. This plan collapsed when I wasn't able to implement any form validation.
What I have now is a list of events on one page, and a confirmation form on another. What I now need is to pull the event name, date and location from the selected event, and pass them across for use in the form. The problem is that wordpress' permalink structure doesn't seem to allow me to add a variable (ie. example.php?variable=1 ).
It it possible to do this?
thanks in advance,
Greg.
Unless you modified something, out of the box Wordpress will allow you to use GET variables, because it uses them too (for previewing posts).
If you installed something that removed all of the GET parameters, you might want to uninstall that. But out of the box Wordpress will let you use GET parameters.
I have tried both GET and POST with no effect. If you have PHP processing a GET variable on a WP Page, the URL is:
/page/?variable=something
And PHP is not recognizing this at all.
Use add_query_arg function. Codex.

Categories