How can i change an image’s author?

You can use wp_update_post() $my_post = array( ‘ID’ => $post_id, ‘post_author’ => $user_id, ); wp_update_post( $my_post ); Or change image’s author via a function using GravityForms uploader add_action(“gform_user_registered”, “image_author”, 10, 4); function image_author($user_id, $config, $entry, $user_pass) { $post_id = $entry[“post_id”]; $args = array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $attachments = … Read more

Beginner question: Accessing functions.php through admin web interface in order to import custom post types?

It is sometimes possible to edit theme files, including functions.php, inside wp-admin. Many hosts and devs disable this feature since it can cause security issues as well as allow you to break the site. So if you can access the file via FTP, that’s generally the recommended method. If you don’t see “Appearance > Editor” … Read more

Replace Archive Widget Link Text

You can use regular expression and the preg_replace_callback() function: function _make_khmer_link_replace_callback( array $matches ) { return ‘<a’ . $matches[1] . ‘>’ . convert_numbers_to_khmer( $matches[2] ) . ‘</a>’; } function make_khmer_link( $link ) { if ( get_bloginfo( ‘language’ ) == ‘km’ ) { $link = preg_replace_callback( ‘#<a(.*?)>(.+?)</a>#’, ‘_make_khmer_link_replace_callback’, $link ); } return $link; } add_filter(‘get_archives_link’, ‘make_khmer_link’); … Read more

Finding post content that begins with a specific character

Something like this will probably work: $results = array(); $allPosts = get_posts(‘post_type=post&numberposts=-1’); foreach ($allPosts as $aPost) { if ( substr($aPost->post_content, 0, 1) == ‘<‘ || substr($aPost->post_content, 0, 2) == ‘<a’ ) $results[] = $aPost->ID; } echo “<pre>”.print_r($results,true).”</pre>”; UPDATE: but you should revisit the MySQL approach in the links you provided. This php method is somewhat … Read more

Customize “the_posts_pagination” and put list instead div

Making your Custom Pagination design In Demo According Your Need . below function Replace Your Function: function wp_custom_pagination($args = [], $class=”pagination”) { if ($GLOBALS[‘wp_query’]->max_num_pages <= 1) return; $args = wp_parse_args( $args, [ ‘mid_size’ => 2, ‘prev_next’ => false, ‘prev_text’ => __(‘Previous’, ‘textdomain’), ‘next_text’ => __(‘Next’, ‘textdomain’), ‘screen_reader_text’ => __(‘Posts navigation’, ‘textdomain’), ]); $links = paginate_links($args); … Read more

Is $hook a global variable in WordPress

Ok – so, firstly you should know that it is a variable and not a function – in php this is indicated by the dollar symbol before the name: $variable as opposed to function() Second, you should note that $hook is passed as a parameter to the function block – like so: function_name( $hook ){ … Read more