Showing posts with label Wordpress. Show all posts
Showing posts with label Wordpress. Show all posts

Monday 19 July 2021

Search and Replace For a Text String in wordpress posts

 

Search and Replace For a Text String

UPDATE wp_posts SET post_content = REPLACE (  post_content,  'text to find here',  'text to replace here');

Sunday 11 October 2015

Wordpress Add multiple custom fields to the general settings page

Add multiple custom fields to the general settings page



function register_fields()
{
    register_setting('general', 'my_first_field', 'esc_attr');
    add_settings_field('my_first_field', '<label for="my_first_field">'.__('My Field' , 'my_first_field' ).'</label>' , 'print_custom_field', 'general');
}

function print_custom_field()
{
    $value = get_option( 'my_first_field', '' );
    echo '<input type="text" id="my_first_field" name="my_first_field" value="' . $value . '" />';
}

add_filter('admin_init', 'register_fields');

Function Reference/get settings
Reading a settings Value in wordpress
<h1><?php echo get_settings('blogname'); ?></h1> 

Thursday 1 October 2015

Recent Post of Particular Parent Category

 Wordpress List Recent Post of Particular Parent Category


<?php $query = new WP_Query( 'category_name=blog&posts_per_page=5' );?>

    <ul>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
      <li> <a href="<?php the_permalink() ?>"><?php the_title();  ?> </a></li>
 <?php endwhile;?>
    </ul>

Thursday 9 July 2015

Stop and Fix WordPress Ask for FTP Credentials

The easiest way to solve this problem is add the following FTP information to your wp-config.php
define('FS_METHOD', 'direct');