Adding Read More to Custom excerpts

To show your custom excerpt more text when a post has a manual excerpt, you can filter the excerpt using the get_the_excerpt filter, use has_excerpt() (http://codex.wordpress.org/Function_Reference/has_excerpt) to determine whether the post has a manual excerpt or not, and append the output of your already-existing custom excerpt more function to the excerpt if not. Here’s some … Read more

Return link pages instead of displaying them

<?php $defaults = array( ‘before’ => ‘<p>’ . __( ‘Pages:’ ), ‘after’ => ‘</p>’, ‘link_before’ => ”, ‘link_after’ => ”, ‘next_or_number’ => ‘number’, ‘separator’ => ‘ ‘, ‘nextpagelink’ => __( ‘Next page’ ), ‘previouspagelink’ => __( ‘Previous page’ ), ‘pagelink’ => ‘%’, ‘echo’ => 0 ); ?> You have to set the echo parameter to … Read more

Add a class to post if it has been recently updated

You’re right. The code you had didn’t use any logic to determine whether to add the CSS class or not. Try this: function skips_add_update_status($classes) { //Instantiates the different date objects $created = new DateTime( get_the_date(‘Y-m-d g:i:s’) ); $updated = new DateTime( get_the_modified_date(‘Y-m-d g:i:s’) ); $current = new DateTime( date(‘Y-m-d g:i:s’) ); //Creates the date_diff objects … Read more

Fill empty custom field with other custom field

Assuming your products are custom posts you can do it like this: add_action(‘wp_insert_post’, ‘do_stuff’); // when product is created add_action(‘save_post’, ‘do_stuff’ ); // on product update function do_stuff( $post_id ) { // Making sure this runs only for products $slug = ‘product_post’; if ( $slug != $_POST[‘post_type’] ) { return; } if (!get_post_meta( $post_id, ‘new_price’, … Read more

Function to pull data from user meta not working

The problem is that when you pass the $key argument on get_user_meta() function, you don’t pass a valid argument. The $key must be a string according to the documentation page. It represents the value of meta_key in the wp_usermeta table. If with wpcf-client-lvl is actually a variable that contains the name of the field ( … Read more

WordPress Website with Login system

Okay, here is a simple example. init action loads before loading WordPress website. So we can use it to check some special conditions for allowing access to users. You should use this in functions.php function user_custom_redirect() { if ( ‘something’ === ‘something else’ ) { // let user view WordPress website } else { // … Read more