Archive for the ‘wordpress’ Category

quick fix, wordpress | No Comments | August 9th, 2014

You may want edit the .htaccess file instead of doing it to your php.ini file. most wp install are hosted on a sharing environment and with no access to the php.ini at all.

just copy and paste the code below to your .htaccess file

########
php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500
#########

Add this PHP code in functions.php file.

 

add_filter( ‘the_content’, ‘prefix_insert_post_ads’ );

function prefix_insert_post_ads( $content ) {

$ad_code = ‘<div> You can add ads code here </div>';

if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 1, $content );
}

return $content;
}

// Parent Function that makes the magic happen

function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = ‘</p>';
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {

if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}

if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}

return implode( ”, $paragraphs );
}

quick fix, wordpress | No Comments | June 12th, 2013

The edit author attribute is not added by default in for custom post types. To add the author attribute the following code is required:

please add this code to function.php in theme folder.

function allowAuthorEditing()
{
  add_post_type_support( 'mytype', 'author' );
}

add_action('init','allowAuthorEditing');

quick fix, wordpress | No Comments | May 23rd, 2013

Please  delete  blank spaces at the top and bottom of functions.php in your theme folder…

wordpress | No Comments | April 22nd, 2013

Add this code to Functions.php file in theme folder.

$subRole = get_role( ’subscriber’ );
$subRole->add_cap( ’read_private_posts’ );
$subRole->add_cap( ’read_private_pages’ );

 

and make post or page in Private mode.

quick fix, wordpress | No Comments | January 31st, 2013

PLease add this code in function.php file from your active Theme folder

 

function szub_nofollow_tag($text) {
return str_replace(‘<a href=’, ‘<a rel=”nofollow” href=’, $text);
}

add_filter(‘wp_tag_cloud’, ‘szub_nofollow_tag’);   /* Will add no follow in tag Cloud */
add_filter(‘the_tags’, ‘szub_nofollow_tag’); /* Will add no follow in Post Tags */

 

 

 

wordpress | No Comments | April 8th, 2011

If you want to make posts orderby custom field … use below code .

proirity = Custom Field name

global $wp_query;

function priority_select($sql){

global $wpdb;

if (strpos($sql, ‘proirity’) !== false){

$sql = str_replace(“ORDER BY {$wpdb->postmeta}.meta_key”, “ORDER BY CAST({$wpdb->postmeta}.meta_key AS UNSIGNED)”, $sql);

}

return $sql;

}



add_filter(‘query’, ‘priority_select’);

query_posts( array_merge(array(‘meta_key’ => ‘proirity’, ‘orderby’=> ‘meta_value’, ‘order’ => ‘asc’), $wp_query->query));

// loop code

wp_reset_query();