How to remove this function from the homepage?
Use is_front_page() and bail at the start of the function if true: function wpb_last_updated_date( $content ) { if ( is_front_page() ) { return $content; } // Rest of your function }
Use is_front_page() and bail at the start of the function if true: function wpb_last_updated_date( $content ) { if ( is_front_page() ) { return $content; } // Rest of your function }
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
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
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
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
OMG… No, no, no!!! Never do that this way… Why? There are many reasons… You won’t be able to do anything with users in your views.php – what if you’ll have to count only views by anonymous (not logged in) users? What if table_prefix is set to ”? Your posts table will cause conflicts… What … Read more
function cc_mime_types($mimes) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; } add_filter(‘upload_mimes’, ‘cc_mime_types’); add in functions.php in your active theme define(‘ALLOW_UNFILTERED_UPLOADS’, true); add in wp-config.php
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
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
It can be used for much about anything that requires php… You’d only use hooks if you don’t want to execute the php logic immediately. This is usually the case, but not always. Likewise, you’d typically use the WP API. But not always either…