Skip to main content

Posts

Showing posts from 2016

GET and Display current page content and Title

<?php $id=12; $post = get_post($id); echo get_the_title( $id ); $content = apply_filters('the_content', $post->post_content); echo $content; $my_postid = 12 ; //This is page id or post id $content_post = get_post ( $my_postid ); $content = $content_post -> post_content ; $content = apply_filters ( 'the_content' , $content ); $content = str_replace ( ']]>' , ']]&gt;' , $content ); echo $content ; ?>

Disable the Plugin and Theme Editor

Access to plugin and theme code is available in the WordPress dashboard. You can do one thing to protect the site from trifile to disable the both of these editors. Open your wp-config.php file and add the following constant: define('DISALLOW_FILE_EDIT',true); Now, when you are in the dashboard it is impossible to access the theme or plugin editor, even if you are admin.

Disable Plugin and Theme Update and Installation

If you really want to disable Updates and Installations, you can block users from installing/updating themes and plugins through the dashboard. Add this quick snippet to your wp-config.php file: define('DISALLOW_FILE_MODS',true); It will prevent users from installing and updating themes and plugins. It will also automatically disable theme and plugin editing in the dashboard.

Add Font to Website Wordpress

a) First download .TTF file of font you want. b) then put it in folder fonts. c) then in css file u are using e.g. style.css d) copy the code shown below :- @font-face{     font-family: test;     src: url("http://abc.com/abc/wp-content/themes/abc/css/fonts/abc.ttf") } e) And use the font where you wont.

Displaying page by calling page number

<?php $args = array(     'sort_order' => 'asc',     'sort_column' => 'post_title',     'hierarchical' => 1,     'exclude' => '',     'include' => '',     'meta_key' => '_thumbnail_id',     'meta_value' => '',     'authors' => '',     'child_of' => 0,     'parent' => 0,     'exclude_tree' => '',     'number' => '',     'offset' => 0,     'post_type' => 'page',     'post_status' => 'publish' ); $mypages = get_pages($args);  //$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );  foreach( $mypages as $page ) {   $content = $page->post_content;   if ( ! $content ) // Check for empty page    continue;   $content = a...

Displaying all pages in dropdown list

Displaying pages in dropdown list   <select name="page-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""> <?php echo esc_attr( __( 'Select page' ) ); ?></option> <?php $pages = get_pages(); foreach ( $pages as $page ) { $option = '<option value="' . get_page_link( $page->ID ) . '">'; $option .= $page->post_title; $option .= '</option>'; echo $option; } ?> </select>  

Displaying Child pages of the current page

<?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) ); foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content', $content ); ?> <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2> <div class="entry"><?php echo $content; ?></div> <?php } ?>

get posts wordpress

    <ul> <?php $the_query = new WP_Query( 'posts_per_page=1' ); ?> <?php //$the_query = new WP_Query( 'showposts=10&offset=1' ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div> <div style="width:104%;"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail();?></a></div><br> <li><div style="font-size: 23px; text-align: center;text-transform: none;"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div></li> <li><div style="margin-bottom: 92px;text-align: center;"> <?php         //$trimtitle = get_the_title();     style="border:1px solid #dedede;margin-bottom: 35px;width:105%;"         //$shorttitle = wp_trim_words( $trimtitle, $num_words = 4, $more = '… ' );         //ech...

get grid posts in wordpress

<style> .gridcontainer h2 a{color: #333; font-size: 13px;} .gridcontainer .griditemleft{float: left; width: 150px; margin: 0 30px 20px 0;} .gridcontainer .griditemright{float: left; width: 150px;} .gridcontainer .postimage{margin: 0 0 5px 0;} .gridcontainer .postimage-title {text-align: center;} </style> <div class="gridcontainer" style="margin-top: -130px;"> <?php // Grid Parameters $counter = 1; // Start the counter $grids = 2; // Grids per row $titlelength = 30; // Length of the post titles shown below the thumbnails // The Query $args=array (     'post_type' => 'post',     'offset'=> 1 ,     'posts_per_page' => 10     ); $the_query = new WP_Query($args); // The Loop while ( $the_query->have_posts() ) :     $the_query->the_post(); // Show all columns except the right hand side column if($counter != $grids) : ?> <div class="griditemleft" ...

get title content in wordpress

<?php        $trimtitle = get_the_title();            $shorttitle = wp_trim_words( $trimtitle, $num_words = 4, $more = '… ' );         echo '<h6 class="info-title">' . '<a href="' . get_permalink() . '">' . $shorttitle . '</a></h6>';         $trimexcerpt = get_the_excerpt();         $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 50, $more = '… ' );         echo '<p>' . $shortexcerpt . '</p>';         ?> <a class="more-link button" href="<?php the_permalink() ?>" style="margin: 23px 0px -24px;">Read More</a>

css 100% responsiveness

  <style> .abc{ normal view } @media screen and (min-width: 767px) {    .abc{ mobile portrait view    } } @media screen and (min-width: 1920px) {    .abc {     above 20 inch displays    }    }     @media only screen   and (min-device-width: 768px)   and (max-device-width: 1024px)   and (-webkit-min-device-pixel-ratio: 1) {     .abc { tablet view }    }     </style> iPad Media Queries (All generations - including iPad mini) iPad in portrait & landscape @media only screen and ( min - device - width : 768px ) and ( max - device - width : 1024px ) { /* STYLES GO HERE */ } iPad in landscape @media only screen and ( min - device - width : 768px ) and ( max - device - width : 1024px ) and ( orientation : landscape ) { /* STYLES GO HERE */ } iPad in portrait @media o...