Two way integration of WordPress with Magento

Most of the Magento users are aware of integrating WordPress with Magento using Fishpig. But Fishpig has some limitation like user can’t use Custom posts, Custom Fields or WordPress codes without using additional paid plugin.

To overcome this, we have found a way. Please follow below steps, this will help you use any WordPress code withing you Magento Installation.

Step 1: Install Fishpig plugin in Magento http://www.magentocommerce.com/magento-connect/wordpress-integration-3795.html

Step 2: Install WordPress plugin and follow installation steps given in it https://wordpress.org/plugins/magento-wordpress-integration/

Step 3: Add below code in index.php file
<?php
$admin = 'admin';
$uri = $_SERVER['REQUEST_URI'];
if(!strpos($uri, $admin) && !strpos($uri, 'downloader')) {
require_once(dirname(__FILE__).'/wordpress/wp-load.php');
}

Thats it, your installation should work now.

Advertisements

WordPress function and its use

<?php bloginfo(‘name’); ?> – Title of the Blog, or Blog Name

<?php wp_title(); ?> – Title of a Specific Page

<?php bloginfo(‘url’); ?> – Exact URL for the Site

<?php bloginfo(‘description’); ?> – Site’s Description

<?php bloginfo(‘template_url’); ?> – Location of Site’s Theme File

<?php bloginfo(‘stylesheet_url’); ?> – Link to the Style.css location

<?php bloginfo(‘rss2_url’); ?> – RSS Feed URL for the Site

<?php bloginfo(‘pingback_url’); ?> – Pingback URL for the site

<?php bloginfo(‘version’); ?> – WordPress Version Number

<?php get_header(); ?> – Displays Header.php file content

<?php get_footer(); ?> – Displays Footer.php file content

<?php get_sidebar(); ?> – Displays Sidebar.php file content

<?php comments_template(); ?> – Displays Comment.php file content

<?php the_content(); ?> – Displays the Content of the Post

<?php the_excerpt(); ?> – Displays the excerpt that is used in Posts

<?php the_title(); ?> – Title of the Specific Post

<?php the_permalink() ?> – Link of the Specific Post

<?php the_category(‘, ‘) ?> – Category of a Specific Post

<?php the_author(); ?> – Author of the Specific Post

<?php the_ID(); ?> – ID of a Specific Post

<?php edit_post_link(); ?> – Edit link for a Post

<?php next_post_link(‘ %link ‘) ?> – URL of the Next Page

<?php previous_post_link(‘%link’) ?> – URL of the Previous Page

<?php get_links_list(); ?> – Lists all links in Blogroll

<?php wp_list_pages(); ?> – Lists all Pages

<?php wp_get_archives() ?> – List Archive for the Site

<?php wp_list_cats(); ?> – Lists all Categories

<?php get_calendar(); ?> – Displays the Built in Calendar

<?php wp_register(); ?> – Displays Register Link

<?php wp_loginout(); ?> – Displays Login/Logout Link only to Registered Users

Display Most popular Posts In WordPress

Add code in your theme where ever you want the popular 5 posts to be displayed.

<ul>
    <?php $pc = new WP_Query('orderby=comment_count&posts_per_page=5'); 
		
      while ($pc->have_posts()) : $pc->the_post(); ?>
		<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
		<p>Posted by <strong><?php the_author() ?></strong> with <?php comments_popup_link('No Comments;', '1 Comment', '% Comments'); ?></p></li>
      <?php endwhile; ?>
</ul>

How to add js and css in wordpress?

/**
 * Proper way to enqueue scripts and styles
 */
function theme_name_scripts() {
	wp_enqueue_style( 'style-name', get_stylesheet_uri() );
	wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

Create Custom Post Type with Texamony(Categories) in WordPress

Custom Post types are very handy tool in wordpress. To create a custom Post Type is pretty easy.

Goto functions.php file of your theme folder and copy the below code. You will get the new section for adding posts. These can be used for many stuffs like creating a small plugin for News, FAQ’s etc.

Below is the code to be added in functions.php. I have added the comment wherever required.

wp-custom-post

Continue reading

Powerful WordPress Tips And Tricks

Piyush Pujara

I’ve been working with WordPress since the dawn of time, and even though I peek at the source code regularly, I still discover new tips and tricks. I’ve compiled my own list of 21 techniques that are handy, clever, fun or best practices rarely followed. I hope everyone finds something new in the list!

1. WordPress Has A Ton Of Built-In Scripts

Using the great wp_enqueue_script() and wp_enqueue_style(), you can include styles and scripts easily with dependency management. But did you know that WordPress has a lot of scripts already built in? jQuery, many elements of jQuery UI, jQuery Form, SWF Object, Tiny MCE, Jcrop and Thickbox are just some the better known ones. The whole list can be found in the WordPress Codex. If you’re interested in learning how to use the enqueue functions effectively, I recommend .The Developer’s Guide to Conflict-Free JavaScript and CSS in WordPress right…

View original post 287 more words

How to get latest article(post) in wordpress.

Get latest 5 post

<?php
$myposts = get_posts('');
foreach($myposts as $post) :
setup_postdata($post);
?>

Get featured image of article

 <?php
the_post_thumbnail('medium'); 
?>

Get post title and its link.

<h3><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h3>

Get limit words of discription.

 <?php
 $excerpt = get_the_excerpt();
 echo string_limit_words($excerpt,25);
?>

Read more link to the post

<a href="<?php the_permalink() ?>">Read More</a>

<?php endforeach; wp_reset_postdata(); ?>

For limit words put following code in function.php in your theme.

function string_limit_words($string, $word_limit)
{
  $words = explode(' ', $string, ($word_limit + 1));
  if(count($words) > $word_limit)
  array_pop($words);
  return implode(' ', $words);
}

latest post