How To Fix Visual Formatting
The following snippet will let you fix visual formatting.
1 2 3 4 5 |
function remove_formatting(){ //Prevents wordpress back-end from stripping formatting remove_filter ('the_content', 'wpautop'); } add_action('init', 'remove_formatting'); |
How To Make Accessible Menu Editor In WordPress
Adding the following snippet to your theme’s functions.php file, you will be able to make accessible menu editor.
1 2 |
$ Role_object = get_role ( 'editor' ) ; $ role_object -> add_cap ( 'edit_theme_options' ) ; |
Snippet Source/Credit: Webundso
How To Simulate A View Of A Page With JavaScript Onclick
Using the following snippet, you will be able to simulate a view of a page with JavaScript onclick.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<input id="submit" onclick="trackpage('/kontaktudfyldt/')" type="submit" value="<?php _e('Send Email', 'framework') ?>" /> <script type="text/javascript"> // <![CDATA[ var readytosubmit = false; function trackpage (track) { _gaq.push(['_trackPageview',track]); readytosubmit = !readytosubmit; setTimeout(clicksubmit(), 100)} function clicksubmit() { document.getElementById("submit").click(); } // ]]> </script> |
Snippet Source/Credit: Reiffs.dk
How To Make Your Search Results Unlimited
Start by finding the below code in your search.php file:
1 2 |
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> |
Once you found it, simply replace it with:
1 2 3 |
<?php $posts=query_posts($query_string . '&posts_per_page=-1'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> |
Snippet Source/Credit: WPHacks
How To Redirect Users To A Random Post In WordPress
Pasting the following snippet to your page-random.php file will let you redirect users to a random post.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// set arguments for get_posts() $args = array( 'numberposts' => 1, 'orderby' => 'rand' ); // get a random post from the database $my_random_post = get_posts ( $args ); // process the database request through a foreach loop foreach ( $my_random_post as $post ) { // redirect the user to the random post wp_redirect ( get_permalink ( $post->ID ) ); exit; } |
Snippet Source/Credit: Smashing Magazine