jQuery, jCarousel, немного PHP и HTML/CSS и получится такая навигация, как у меня внизу на главной. При желании можно доделать до любой формы. Еще это минус один плагин, что есть гуд в плане ресурсов. Read On…
Archive for the ‘Wordpress’ Category
Creative By Nature- бесплатная темка для вп
Еще одна прикольная бесплатная темка — Creative by Nature от .css{mayo}
Демка тут
Скачать архив
Скачать исходники Read On…
Related posts без плагинов
Потихоньку убираю плагины с блога. В sidebar.php:
<?php if(is_single()){?> <div id="related"> <?php $tags = wp_get_post_tags($post->ID); if ($tags) { echo '<strong>Схожие посты</strong>'; $first_tag = $tags[0]->term_id; $args=array( 'tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'showposts'=>5, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Постоянная ссылка <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></p> <?php endwhile; } } ?> </div> <?php } ?>
Подглядел тут
Баги — если код вставляется до коментов, то коменты отображаются от другого поста. Либо после вывода вставлять либо ковырять код.
Выводим превьюшки картинок в вордпрессе
Вывести превьюшки на главной можно средствами самого вордпресса, не колдуя с custom fields. Надо добавить код на главную, архивы или где еще надо выводить тумбы. Я вот топорно так вывел, но думаю смысл понятен
[audio:http://alexvolkov.ru/audio/test.mp3]
<?php //Get images attached to the post $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'order' => 'ASC', 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { $img = wp_get_attachment_thumb_url( $attachment->ID ); break; } //Display image } ?>
Включаем gravatar
Одна маленькая строчка —
<?php if(function_exists('get_avatar')) { echo get_avatar($comment, '70'); } ?>
а сколько счастья.
Бесплатная тема для вп — Paper Wall
XML-RPC wordpress
Note: This API is current as of the 2.7.1 release.
wp.getUsersBlogs
Retrieve the blogs of the users.
Parameters
- string username
- string password
Return Values
- array
- struct
- boolean is_admin
- string url
- int blog_id
- string blog_name
- string xmlrpc_url
- struct
wp.getTags
Get list of all tags.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct
- int tag_id
- string name
- int count
- string slug
- string html_url
- string rss_url
- struct
wp.getCommentCount
Retrieve comment count for a specific post.
Parameters
- int blog_id
- string username
- string password
- string post_id
Return Values
- array
- struct
- int approved
- int awaiting_moderation
- int spam
- int total_comments
- struct
wp.getPostStatusList
Retrieve post statuses.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- const string ‘draft’
- const string ‘pending’
- const string ‘private’
- const string ‘publish’
wp.getPageStatusList
Retrieve all of the WordPress supported page statuses.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- const string ‘draft’
- const string ‘private’
- const string ‘publish’
wp.getPageTemplates
Retrieve page templates.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct
- string name
- string description
- struct
wp.getOptions
Retrieve blog options. If passing in an array, search for options listed within it.
Parameters
- int blog_id
- string username
- string password
- array
- string option
Return Values
- array
- struct
- string option
- string value
- struct
wp.setOptions
Update blog options. Returns array of structs showing updated values.
Parameters
- int blog_id
- string username
- string password
- array
- struct
- string name
- string value
- struct
Return Values
- array
- struct
- string option
- string value
- struct
wp.deleteComment
Remove comment.
Parameters
- int blog_id
- string username
- string password
- int comment_id
Return Values
- boolean status
wp.editComment
Edit comment.
Parameters
- int blog_id
- string username
- string password
- int comment_id
- struct comment
- string comment_status
- date date_created_gmt
- string content
- string author
- string author_url
- string author_email
Return Values
- boolean status
wp.newComment
Create new comment.
Parameters
- int blog_id
- string username
- string password
- int post_id
- struct comment
- int comment_parent
- string content
- string author
- string author_url
- string author_email
Return Values
- int comment_id
wp.getCommentStatusList
Retrieve all of the comment status.
Parameters
- int blog_id
- string username
- string password
Return Values
- struct
- string hold
- string approve
- string spam
wp.getPage
Get the page identified by the page id.
Parameters
- int blog_id
- int page_id
- string username
- string password
Return Values
- struct
- datetime dateCreated (ISO.8601)
- int userid
- int page_id
- string page_status
- string description
- string title
- string link
- string permaLink
- array categories
- string Category Name
- …
- string excerpt
- string text_more
- int mt_allow_comments
- int mt_allow_pings
- string wp_slug
- string wp_password
- string wp_author
- int wp_page_parent_id
- string wp_page_parent_title
- int wp_page_order
- int wp_author_id
- string wp_author_display_name
- datetime date_created_gmt
- array custom_fields
- struct
- string id
- string key
- string value
- …
- struct
- string wp_page_template
wp.getPages
Get an array of all the pages on a blog.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct Same as wp.getPage
- …
wp.getPageList
Get an array of all the pages on a blog. Just the minimum details, lighter than wp.getPages.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct
- int page_id
- string page_title
- int page_parent_id
- datetime dateCreated
- …
- struct
wp.newPage
Create a new page. Similar to metaWeblog.newPost.
Parameters
- int blog_id
- string username
- string password
- struct content
- string wp_slug
- string wp_password
- int wp_page_parent_id
- int wp_page_order
- int wp_author_id
- string title
- string description (content of post)
- string mt_excerpt
- string mt_text_more
- int mt_allow_comments (0 = closed, 1 = open)
- int mt_allow_pings (0 = closed, 1 = open)
- datetime dateCreated
- array custom_fields
- struct
- Same struct data as custom_fields in wp.getPage
- bool publish
Return Values
- int page_id
wp.deletePage
Removes a page from the blog.
Parameters
- int blog_id
- string username
- string password
- int page_id
Return Values
- bool true
wp.editPage
Make changes to a blog page.
Parameters
- int blog_id
- int page_id
- string username
- string password
- struct content
- Same struct data as newPage
- bool publish
Return Values
- bool true
wp.getAuthors
Get an array of users for the blog.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct
- int user_id
- string user_login
- string display_name
- string user_email
- string meta_value (Serialized PHP data)
- …
- struct
wp.getCategories
Get an array of available categories on a blog.
Parameters
- int blog_id
- string username
- string password
Return Values
- array
- struct
- int categoryId
- int parentId
- string description
- string categoryName
- string htmlUrl
- string rssUrl
- …
- struct
wp.newCategory
Create a new category.
Parameters
- int blog_id
- string username
- string password
- struct
- string name
- string slug
- int parent_id
- string description
Return Values
- int category_id
wp.deleteCategory
Delete a category.
Parameters
- int blog_id
- string username
- string password
- int category_id
Return Values
- ?
wp.suggestCategories
Get an array of categories that start with a given string.
Parameters
- int blog_id
- string username
- string password
- string category
- int max_results
Return Values
- array
- struct
- int category_id
- string category_name
- …
- struct
wp.uploadFile
Upload a file.
Parameters
- int blog_id
- string username
- string password
- struct data
- string name
- string type
- base64 bits
- bool overwrite
Return Values
- struct
- string file
- string url
- string type
wp.getComment
Gets a comment, given it’s comment ID. Note that this isn’t in 2.6.1, but is in the HEAD (so should be in anything newer than 2.6.1)
Parameters
- int blog_id
- string username
- string password
- int comment_id
Return Values
- struct
- datetime dateCreated (ISO.8601, always GMT)
- string user_id
- string comment_id
- string parent
- string status
- string content
- string link
- string post_id
- string post_title
- string author
- string author_url
- string author_email
- string author_ip
wp.getComments
Gets a set of comments for a given post. Note that this isn’t in 2.6.1, but is in the HEAD (so should be in anything newer than 2.6.1).
Parameters
- int blog_id
- string username
- string password
- struct
- post_id
- status (approve is good. blank means ALL)
- offset
- number
Return Values
Returns an array of the comment structure (see wp.getComment)
- struct
- datetime dateCreated (ISO.8601, always GMT)
- string user_id
- string comment_id
- string parent
- string status
- string content
- string link
- string post_id
- string post_title
- string author
- string author_url
- string author_email
- string author_ip
http://codex.wordpress.org/XML-RPC_wp
Постим в твиттер через курл
Можно интегрировать в свой блог, и пост автоматом уйдет в твиттер, можно встроить в админку и писать в твиттер из админки вп. Применений масса.
<?php // Set username and password $username = 'username'; $password = 'password'; // The message you want to send $message = 'is twittering from php using curl'; // The twitter API address $url = 'http://twitter.com/statuses/update.xml'; // Alternative JSON version // $url = 'http://twitter.com/statuses/update.json'; // Set up and execute the curl process $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); $buffer = curl_exec($curl_handle); curl_close($curl_handle); // check for success or failure if (empty($buffer)) { echo 'message'; } else { echo 'success'; } ?>
Пример простой спамилки вордпресса
У курла есть много вариантов использования )
<?php $postfields = array(); $postfields["action"] = "submit"; $postfields["author"] = "Spammer"; $postfields["email"] = "spammer@spam.com"; $postfields["url"] = "http://www.iamaspammer.com/"; $postfields["comment"] = "I am a stupid spammer."; $postfields["comment_post_ID"] = "123"; $postfields["_wp_unfiltered_html_comment"] = "0d870b294b"; //Url of the form submission $url = "http://www.ablogthatdoesntexist.com/blog/suggerer_site.php ?action=meta_pass&id_cat=0"; $useragent = "Mozilla/5.0"; $referer = $url; //Initialize CURL session $ch = curl_init($url); //CURL options curl_setopt($ch, CURLOPT_POST, 1); //We post $postfields data curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); //We define an useragent (Mozilla/5.0) curl_setopt($ch, CURLOPT_USERAGENT, $useragent); //We define a refferer ($url) curl_setopt($ch, CURLOPT_REFERER, $referer); //We get the result page in a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //We exits CURL $result = curl_exec($ch); curl_close($ch); //Finally, we display the result echo $result; ?>
Пишем в вордпресс через curl
Данной функцией можно постить в вп.
function wpPostXMLRPC($title,$body,$rpcurl,$username, $password,$category,$keywords='',$encoding='UTF-8') { $title = htmlentities($title,ENT_NOQUOTES,$encoding); $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding); $content = array( 'title'=>$title, 'description'=>$body, 'mt_allow_comments'=>0, // 1 to allow comments 'mt_allow_pings'=>0, // 1 to allow trackbacks 'post_type'=>'post', 'mt_keywords'=>$keywords, 'categories'=>array($category) ); $params = array(0,$username,$password,$content,true); $request = xmlrpc_encode_request('metaWeblog.newPost',$params); $ch = curl_init(); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_URL, $rpcurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); $results = curl_exec($ch); curl_close($ch); return $results; ?>