wordpress show latest post from each category

Many people want to show wordpress show latest post from each category posts from there selected categories or all categories on home page. Here we given code snippet for this.
I this article I will show how easily you can achieve this.

wordpress show latest post from each category

Please following code in your home page which is your theme’s index.php file.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span>-->
$categories=get_categories($all_categories);
 foreach($categories as $category) {
 $post_args=array(
 'showposts' =--> 1, // you can fetch number of articles from each category
 'category__in' => array($category->term_id),
 'caller_get_posts'=>1
 );
 $posts=get_posts($post_args);
 if ($posts) {
 echo '</pre>
Category: sprintf( __( " href="' . get_category_link( $category->term_id ) . '">name ) . '" ' . '>' . $category->name.'</pre>
<pre> ';foreach($posts as $post) {</pre>
<pre>
 setup_postdata($post); ?></pre>
<div>

php the_title_attribute(); ?>" href="<!--?php the_permalink() ?-->" rel="bookmark">
 <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_title(); ?-->

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_excerpt(); ?-->

</div>
<pre>
 <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span>-->
 } // foreach($posts
 } // if ($posts
 } // foreach($categories
?-->

if you want to show the posts from specific articles then use following code.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span>-->
$selected_categories=array(
 'include' =--> '1,4,9',
 'order' => 'ASC'
 );

$categories=get_categories($selected_categories);foreach($categories as $category) {
 $post_args=array(
 'showposts' => 1, // you can fetch number of articles from each category
 'category__in' => array($category->term_id),
 'caller_get_posts'=>1
 );
 $posts=get_posts($post_args);
 if ($posts) {
 echo '</pre>
Category: sprintf( __( " href="' . get_category_link( $category->term_id ) . '">name ) . '" ' . '>' . $category->name.'</pre>
<pre> ';foreach($posts as $post) {</pre>
<pre>
 setup_postdata($post); ?></pre>
<div>

php the_title_attribute(); ?>" href="<!--?php the_permalink() ?-->" rel="bookmark">
 <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_title(); ?-->

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_excerpt(); ?-->

</div>
<pre>
 <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span>-->
 } // foreach($posts
 } // if ($posts
 } // foreach($categories
?-->

how to add users in wordpress website

If youโ€™d like your blog to feature posts from multiple authors, how to add users in wordpress website, you can add as many administrative accounts to your blog as you like. There are two different ways to add users. There are two different ways to add a new user to your blog, depending on whether or not that person already has an account at WordPress.com.

how to add users in wordpress website

how to add users in wordpress website
how to add users in wordpress website

 

To add someone who already has a WordPress.com account:

  • Log in to your dashboard.
  • Click on the Users -> Authors & Users menu option.
  • In the Add User From Community section at the bottom, enter the authorโ€™s email address in the User E-mail box
  • Select either Contributor, Author or Editor in the Role list
  • Click the Add User button
  • Your new user will now see your blog listed in their dashboard when they log in to WordPress.com.

To add someone who does not have a WordPress.com account:

  • Log in to your dashboard.
  • Click on the Users -> Invites menu option.
  • Enter the authorโ€™s first name, last name and email address in the appropriate fields.
  • Check the box labeled Add user to my blog as a contributor.
  • Click the Send Invite button.
  • Your new user will receive an email inviting them to sign up for a WordPress.com account (and, optionally, create their own blog if they want). Once they have signed up, youโ€™ll see them listed as a Contributor on your Users tab. You can change them to a different role (Author or Editor) later if youโ€™d like.

The difference between each of the roles is explained in the User Roles documentation.

Warning: Please be very careful when adding a new Administrator user to your blog. Other Administrators are effectively co-owners. They have as much power over your blog as you do, including the ability to permanently delete it.

Transfer Note: For security purposes, there is no way to remove the original creator/owner from their blog. As such, if you wish to transfer your blog to another user/account, please follow the instructions here.

Video

Watch the โ€œAdding users to your blog (or removing them)โ€ video from WordPress.tv.

Adding users to your blog (or removing them)

Adding users to your blog (or removing them)

This movie requires Adobe Flash for playback.

Watch the โ€œInviting your friends to WordPress.comโ€ video from WordPress.tv.

Inviting your friends to WordPress.com

Inviting your friends to WordPress.com

This movie requires Adobe Flash for playback.

Was this Helpful?


How to wordpress change admin username

You cannot change a WordPress.com account username once it has been set. However, you can change what is seen on your posts and comments by changing the display name (nickname) in your profile, or you can create a new account and transfer your blog(s) to the new account.

How to wordpress change admin username

wordpress change admin username
wordpress change admin username

Change Display Name (Nickname)

1. Access your User Profile

2. Change the value next to Display name publicly as under Basic Details

3. Click Update Profile.

โ†‘ Table of Contents โ†‘

Change Username

1. Log into your current account (using your existing username)

2. Access your Personal Settings and change the e-mail address to another email address. This will free up your primary e-mail for use with the new username.

3. Once the new address has been verified via email confirmation, log out of the account.

4. Go to http://wordpress.com/signup/ and attempt to register a new account (the username you wish to change to) with your e-mail address.

5. If youโ€™ve got a blog you should transfer its ownership to your new username.

Once youโ€™ve done all of that youโ€™ll be rocking WordPress.com with your new username.

via Change Your Username ยซ Support.

how to work with wordpress plugin filters

Filters are hooks that WordPress launched to modify text of various types before saving to database. we explained how to work with wordpress plugin filters.ย Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

how to work with wordpress plugin filters
how to work with wordpress plugin filters

All filters are located in wp-includes/plugin.php file. Following function you can use for using the filters in wordpress plugin.

has filter

Check if any filter has been registered for a hook.

<!--?phpย has_filters(ย $tag,ย $function_to_checkย );ย ?--> 

$tag

(string) (required) The name of the filter hook.

Default: None

$function_to_check
(callback) (optional) If specified, return the priority of that function on this hook or false if not attached.

Default: False

add filter

add_filter( $tag, $function_to_add, $priority, $accepted_args );

$tag
(string) (required) The name of the filter to hook the $function_to_add to.

Default: None

$function_to_add
(callback) (required) The name of the function to be called when the filter is applied.

Default: None

$priority
(integer) (optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

Default: 10

$accepted_args
(integer) (optional) The number of arguments the function(s) accept(s). In WordPress 1.5.1 and newer. hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run.

Default: 1

example

add_filter('media_upload_newtab', array(&$this, 'media_upload_mycallback')); 

apply filters

apply_filters( $tag, $value ); 

$tag
(string) (required) The name of the filter hook.

Default: None

$value
(mixed) (required) The value which the filters hooked to $tag may modify.

Default: None

example.

$myvar = apply_filters( $tag, $value );

current filter

Retrieve the name of the current filter or action.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php current_filter() ?>

merge filters

Merge the filter functions of a specific filter hook with generic filter functions.

merge_filters($tag);

$tag
(string) (required) The filter hook of which the functions should be merged.

Default: None

remove filter

This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute. See also remove_action(), add_filter() and add_action().
Important: Because of long-time unfixed bugs resulting in flaws of the underlying implementation, it is unpredictable which filters this function will remove when called. Usage might/will result in loss of other then the intended filter(s). Plugin authors should prevent the usage of this function if possible.

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

$tag
(string) (required) The action hook to which the function to be removed is hooked.

Default: None

$function_to_remove
(string) (required) The name of the function which should be removed.

Default: None

$priority
(int) (optional) The priority of the function (as defined when the function was originally hooked).

Default: 10

$accepted_args
(int) (optional) The number of arguments the function accepts.

Default: 1

remove all filters

Remove all of the hooks from a filter.

 remove_all_filters( $tag, $priority );

$tag
(string) (required) The filter to remove hooks from.

Default: None

$priority
(integer) (optional) The priority number to remove.

Default: false

——————————————-x———————————–x—————————–

All List of all WordPress filter hooks you will find on following URL

http://adambrown.info/p/wp_hooks/hook/filters

how to prevent spam comments wordpress

If you are internet user then you know about what is spam. You know or saw spam emails earlier so many times. prevent spam comments wordpress is big task and important also.

how to prevent spam comments wordpress

how to prevent spam comments wordpress
how to prevent spam comments wordpress

Comment Spam Hacks

The following are not recommended for average users. They involve editing WordPress core files. BACKUP your files first.

  • Delete wp-comments-post.php

The ultimate end-all solution to your comment spam troubles. This will effectively disable comments and is good for stopping comment spam floods. No one will be able to comment on your WordPress site.

  • Delete wp-trackback.php

The ultimate end-all solution to your trackback spam troubles. This will effectively disable trackbacks and is good for stopping trackback spam floods. This will mean that no one will be able to trackback your posts, so do this after consideration.

  • Denying access with .htaccess

While drastic, you can make modifications in your .htaccess file if you are using an Apache server. Check the Internet and Apache for more information.

  • Use nofollow

The nofollow attribute is another method used to strip spammers of their page ranks. According to Google, “when Google sees the attribute (rel=”nofollow”) on hyperlinks, those links won’t get any credit when we rank websites in our search results.” Under WordPress v1.5, the nofollow attribute is automatically added to all links in the comments section.

WordPress comes with a pre installed antispam solution – Akismet.

In order to use Akismet, you should have a WordPress API key. To receive a WordPress API key, you should register at the official WordPress website. The key will be included in your welcome mail.

If you already have a registration at WordPress.org, you can see your API key by visiting the WP dashboard.

To enable Akismet for your blog, follow the steps below:

Step 1. Go to your WordPress admin area > Plugins > Installed.

Step 2. Click Activate.

There are many ways to protect your WordPress.com blogs from unwanted comments:

* WordPress.com blogs are protected by the Akismet comment spam filter.
* You can control whether comments are automatically approved or if they need to be reviewed before they are published.
* You can add rules for comment moderation to control which comments get marked as pending.
* You can add rules to the comment blacklist section to automatically mark some comments as spam.
* If you turn on email notifications, then you can watch those messages for spam and delete them quickly if you find any that get through the comment spam filter.

Akismet learns by those who mark comment spam as comment spam and legitimate spam is despammed. If your comments are being caught by Akismet, remove them from the Akismet Panel. It might take two or three times, but it will learn and automatically not designate your comments as spam.

Commenters on your blog may have their comments caught by Akismet. If you do not regularly check your Akismet Panel, have an easy way of allowing readers to email you if their comment did not appear.

With updates to the database and major changes to the software, this process may have to be repeated.

If you continue to have problems with Akismet catching your comments or too many of your readers’ comments, contact Akismet for more assistance.

How to use smiley images in wordpress posts

If you want to use smiley images in wordpress posts then you can use our tricks. Here in this article, we given sample and trick for using smiley in posts.

Follow our steps.

  1. Find your smiley image files in the /wp-includes/images/smilies directory and back them up to another directory
  2. Note the names of each smiley file. Your files must match these names and should be in the same ‘gif’ image format.
  3. For predictable behavior, the image sizes should be similar.
  4. Upload your new files to the /wp-includes/images/smilies directory with an FTP program.

How to use smiley images in wordpress posts

How to use smiley images in wordpress posts
How to use smiley images in wordpress posts

If you want to changes the names of smiley and you need to edit wp-includes/functions.php file.

In that file you will find the “smilies_init” function.

You will find the following code in that file.


if ( !isset( $wpsmiliestrans ) ) {
 $wpsmiliestrans = array(
 ':mrgreen:' => 'icon_mrgreen.gif',
 ':neutral:' => 'icon_neutral.gif',
 ':twisted:' => 'icon_twisted.gif',
 ':arrow:' => 'icon_arrow.gif',
 ':shock:' => 'icon_eek.gif',
 ':smile:' => 'icon_smile.gif',
 ':???:' => 'icon_confused.gif',
 ':cool:' => 'icon_cool.gif',
 ':evil:' => 'icon_evil.gif',
 ':grin:' => 'icon_biggrin.gif',
 ':idea:' => 'icon_idea.gif',
 ':oops:' => 'icon_redface.gif',
 ':razz:' => 'icon_razz.gif',
 ':roll:' => 'icon_rolleyes.gif',
 ':wink:' => 'icon_wink.gif',
 ':cry:' => 'icon_cry.gif',
 ':eek:' => 'icon_surprised.gif',
 ':lol:' => 'icon_lol.gif',
 ':mad:' => 'icon_mad.gif',
 ':sad:' => 'icon_sad.gif',
 '8-)' => 'icon_cool.gif',
 '8-O' => 'icon_eek.gif',
 ':-(' => 'icon_sad.gif',
 ':-)' => 'icon_smile.gif',
 ':-?' => 'icon_confused.gif',
 ':-D' => 'icon_biggrin.gif',
 ':-P' => 'icon_razz.gif',
 ':-o' => 'icon_surprised.gif',
 ':-x' => 'icon_mad.gif',
 ':-|' => 'icon_neutral.gif',
 ';-)' => 'icon_wink.gif',
 '8)' => 'icon_cool.gif',
 '8O' => 'icon_eek.gif',
 ':(' => 'icon_sad.gif',
 ':)' => 'icon_smile.gif',
 ':?' => 'icon_confused.gif',
 ':D' => 'icon_biggrin.gif',
 ':P' => 'icon_razz.gif',
 ':o' => 'icon_surprised.gif',
 ':x' => 'icon_mad.gif',
 ':|' => 'icon_neutral.gif',
 ';)' => 'icon_wink.gif',
 ':!:' => 'icon_exclaim.gif',
 ':?:' => 'icon_question.gif',
 );

You can edit that names as per your requirement and add more smiley.

If you want to put some css for your smiley then you can use or put following CSS class in your style.css file (Theme folder).

img.wp-smiley {
   float: none;
   padding:2px;
   border:none;
}

That sit! Have fun.

Use smilies/smileys in wordpress posts

By default, WordPress automatically converts text smileys to graphic images. In this post I showed how to Use smilies/smileys in wordpress posts

Use smilies/smileys in wordpress posts

Use smilies/smileys in wordpress posts
Use smilies/smileys in wordpress posts

Smileys, also known as “emoticons,” are glyphs used to convey emotions in your writing. They are a great way to brighten up posts. smile emoticon

By default, WordPress automatically converts text smileys to graphic images. When you type ๐Ÿ˜‰ in your post you see smile emoticon when you preview or publish your post.

If you turn off graphic smileys, whatever you type in plain text will remain, and be displayed, as plain text.

  1. Go to your Admin Panel
  2. Select Settings -> Writing
  3. In the Formatting section, uncheck the box for “Convert emoticons likeย ๐Ÿ™‚ andย ๐Ÿ˜› to graphics on display

Turning off emoticons means that when you type ๐Ÿ˜‰ in a post you will see ๐Ÿ˜‰ when you preview or publish your post. So it doesn’t stop you from using emoticons as plain text. wink emoticon

What Text Do I Type to Make Smileys?

Smiley images and the text used to produce them*:

icon text text full text icon full text
smile ๐Ÿ™‚ ๐Ÿ™‚ ๐Ÿ™‚ lol ๐Ÿ˜†
biggrin ๐Ÿ˜€ ๐Ÿ˜€ ๐Ÿ˜€ redface ๐Ÿ˜ณ
sad ๐Ÿ™ ๐Ÿ™ ๐Ÿ™ cry ๐Ÿ˜ฅ
surprised ๐Ÿ˜ฎ ๐Ÿ˜ฎ ๐Ÿ˜ฎ evil ๐Ÿ‘ฟ
eek ๐Ÿ˜ฏ ๐Ÿ˜ฏ ๐Ÿ˜ฏ twisted ๐Ÿ˜ˆ
confused ๐Ÿ˜• ๐Ÿ˜• ๐Ÿ˜• rolleyes ๐Ÿ™„
cool 8) ๐Ÿ˜Ž ๐Ÿ˜Ž exclaim โ—
mad ๐Ÿ˜ก ๐Ÿ˜ก ๐Ÿ˜ก question โ“
razz ๐Ÿ˜› ๐Ÿ˜› ๐Ÿ˜› idea ๐Ÿ’ก
neutral ๐Ÿ˜ ๐Ÿ˜ ๐Ÿ˜ arrow โžก
wink ๐Ÿ˜‰ ๐Ÿ˜‰ ๐Ÿ˜‰ mrgreen :mrgreen:

* In some instances, multiple text options are available to display the same smiley.

Note: The smiley or emoticon image graphics are found in the /wp-includes/images/smilies directory.


how to use update option in wordpress plugin

Most of wordpress plugin writer choose the new table for saving data for plugin setting and any setting in wordpress plugin. In this article we will show, how to use update option in wordpress plugin.ย  I recommend to use the update option for saving data in wordpress database.

how to use update option in wordpress plugin

how to use update option in wordpress plugin
how to use update option in wordpress plugin

There is ready made option is provided by wordpress to save custom data in there table.

Here with very simple code I will show how use save the data in wordpress database.

&lt; ?php
$variable = array(โ€˜var1โ€ฒ =&gt; $_POST['var1'], โ€˜var2โ€ฒ =&gt; $_POST['var2']);
update_option(โ€˜myPlugin_var1โ€ฒ, serialize($variable));
get_option(โ€˜myPlugin_var1โ€ฒ) == โ€œโ€ ? โ€œโ€ : $new = unserialize(get_option(โ€˜myPlugin_var1โ€ฒ));
?&gt;

You should save data in simple variable format or I suggest always save data in array format.

For more reference you can check the following URL
http://phpxref.com/xref/wordpress/wp-admin/options.php.source.html

how to add text in footer wordpress

You can add your text before footer area. Using our code you can easily achieve this. In this article I will show you how to add text in footer wordpress. In this article I will show you how to add the text before footer area in wordpress.

how to add text in footer wordpress

how to add text in footer wordpress
how to add text in footer wordpress

First Open your functions.php file from your wordpress theme and use following code in the functions.php


function custom_footer() {
 $content = '</pre>
<div id="custom_footer">this is your custom function or text</div>
<pre>';
 echo $content;
}
add_action('wp_footer', 'custom_footer');

Then open your footer.php file from wordpress theme folder and put following code in footer where you want to show your custom text or function.


<?php wp_footer(); ?>

how to change wordpress post order category wise

When we need to re-arrange my recent post in wordpress. they go Ascending/Descending order category wise. Code for change wordpress post order category wise. We can easily achieve this using wordpress api.

how to change wordpress post order category wise

how to change wordpress post order category wise
how to change wordpress post order category wise

use following code:


<!--?php

//The Query
query_posts('cat=1,3,3&posts_per_page=15&order=ASC');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
 ..
endwhile; else:
 ..
endif;

?-->