Category: Wordpress Tips


Last week, i was doing a PSD to wordpress CMS work. There was a footer menu, in which pages are separated by a horizontal line. I just simply listed the pages and added line as border in CSS.

#nav li a{border-right: 1px solid #ccc;}

But the client said they want a ‘printer friendly’ menu seperated with “|” symbol.

a menu like this:

Home  |   About  |  Contact 

The list pages function, displays only as a list, ie it adds html tag <li&> and </li&> to every elements. It will result only vertical list with bullets if css is disabled.

There is a way to remove thos “li”s. using the the preg_replace php function

here is the code to display wordpress pages separated with |


<a href="/">
Home

<?php $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
$pages = preg_replace('%

  • ]+)>%U',' | ', $pages);
    $pages = str_replace('
  • ','', $pages);
    echo $pages; ?>

    This will replace li with span and ‘|’. This can be used to add more tags like divs or span in the page list.

    same code can be used with list category function also

    Advertisements

    If you are using a free wordpress theme, you may find some bad codes in the footer.php file. No problem, it is not a virus. It is the encrypted footer.

    Many of the free WordPress themes comes with encrypted footer. It contains the credit links to the auther. The authors are encrypting this to avoid link removal. Those themes are made free for you because of these credit links. Many theme authers will encrypt this. The encrypted footer causes many problem.  For many applications like google analytics, Payperpost etc. a code is need to be pasted in footer. The encrypted footer will not  allow this.

    encoded

    In such cased you need not change the template. Here is a way for Removing WordPress Theme Footer Encryption.
    Step1: Log-in to wp-admin and Go to http://xxxxxxxx.xxx/wp-admin/theme-editor.php

    On the right side of the editor, you will find many files like archieves.php, header.php, sidebar.php, footer.php, index.php etc. Go to main index template by clicking on index.php

    In some themes there may be a file called Home.php In such themes, go to edit that file.

    At the end of that file you can find a code:

    <?php get_footer(); ?>

    Change it into:

    <!--Footer code starts here-->
    
    <?php get_footer(); ?>
    
    <!--Footer code ends here-->

    Then Open the site. Then view the source code. It can be viewed by clicking View -> Source (in explorer) or  View -> Page Source (in firefox).  At the end you can see some code between the 2 strings.

    <!--Footer code starts here-->
    
        footer code
    
    <!--Footer code ends here-->

    Copy the code between<!–Footer code starts here–> and<!–Footer code ends here–> and paste it to the footer.php in the theme editor.
    U decoded it. Now you can paste Google analytics code in the footer. Or web site tracker or code from http://whos.amung.us to find how many people online.

    One more thing, Don’t forget to add “wp_footer()” function. Some plugins have to add some php codes in the footer. Such plugins won’t work if ther’s no wp_footer function.  It’s easy. Just paste

    <?php wp_footer(); ?>

    before </body> tag.

    Make sure that  you are not removing the credit links or sponsor links. Because you are enjoying a free theme because of that link (Be honest). These links will not cause any problem for your blog.

    Some authers allow removal of such links by paying a small amount to them.

    In some themes there may a widget enabled footer. In such themes after decoding you will get static code. In such cases find the code for widgets from wordpress support forum.