Archive for the ‘Web’ Category

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 } ?>

Подглядел тут
Баги — если код вставляется до коментов, то коменты отображаются от другого поста. Либо после вывода вставлять либо ковырять код.

Количество подписчиков фидбернера числом.

<?php
$feed = 'https://feedburner.google.com/
api/awareness/1.0/GetFeedData?uri=ИмяФида';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed);
$feed = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($feed);
$fb = $xml->feed->entry['circulation'];
echo $fb;
?>

результат в сайдбаре

Выводим превьюшки картинок в вордпрессе

Вывести превьюшки на главной можно средствами самого вордпресса, не колдуя с 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
} ?>

Read On…

Яндекс теперь проверяет правописание.

Точнее проверяет его он уже давно, теперь открыт доступ к апи яндекс.спеллера, можно воткнуть себе на сайт и радоваться грамотности. Словарь довольно большой, 3,8 млн. словоформ.
http://clubs.ya.ru/company/replies.xml?item_no=17937&ncrnd=4311

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

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

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

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

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

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

Return Values

  • array
    • struct
      • string option
      • string value

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
    • 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


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

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
  • 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)

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

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

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

css.php