Has anyone tried putting PHP ActiveRecord on WordPress?

If you plan to use it just for your own code, and have it running alongside WordPress’ default database driver (wpdb), I see no real problems. It’s only if you plan on fully integrating/overriding WP’s driver that I see it being near-impossible; hard-coded SQL is prolific throughout core, and translating them to ActiveRecord method calls … Read more

the_author_posts_link css class

You can use the the_author_posts_link filter to add the custom blog-link class: /** * Add the ‘blog-link’ class to the output of the_author_posts_link() */ add_filter( ‘the_author_posts_link’, function( $link ) { return str_replace( ‘rel=”author”‘, ‘rel=”author” class=”blog-link”‘, $link ); });

If Custom Field is empty don’t display div

Try this: <?php $business_services = get_field( “services_for_businesses” ); //etc… ?> <div class=”section-title”>Services for Individuals</div> <div class=”section-text”> <?php the_field(‘services_for_individuals’) ?> </div> <?php if ( $business_services ) : ?> <div class=”section-title-business”>Services for Businesses</div> <div class=”section-text”> <?php echo $business_services; ?> </div> </div> <?php endif; ?> </div> Further abstract the code to meet your needs if you have more … Read more

How to add query vars with paginated URLs?

Use the add_args parameter to add an array of query string arguments to pagination links: echo paginate_links( array( ‘base’ => add_query_arg( ‘cpage’, ‘%#%’ ), ‘format’ => ”, ‘prev_text’ => __(‘&laquo;’), ‘next_text’ => __(‘&raquo;’), ‘total’ => ceil($total / $items_per_page), ‘current’ => $page, ‘add_args’ => array( ‘category’ => ‘fruit’, ‘color’ => ‘red’ ) ));

Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress

If WordPress is loaded from outside of the main WordPress files using a separate PHP script that includes wp-load.php then the /template-loader.php file will not be loaded and therefore the template_redirect action will not be triggered. This is important because template_redirect is how the Toolbar is initialized on the front end. Taking a look at … Read more

Change Password Hint

Just add a filter, where you can change the text, like this: add_filter( ‘password_hint’, function( $hint ) { return __( ‘MY OWN PASSWORD HINT’ ); } ); This can be added in functions.php in your theme. A bit of an explanation there in core you can see: return apply_filters( ‘password_hint’, $hint ); that is where … Read more

How to retrieve a value from get_posts()? [closed]

Each post is an object, which changes the syntax you need to use to access the post name: $arr = get_posts(); $arr = array_reverse($arr); foreach ($arr as $post) { echo $post->post_name; echo “<br/>”; } As a side point, a slightly easier (and computationally more efficient) way to get your posts in reverse order is to … Read more

How to handle a custom form in wordpress to submit to another page?

<form action=”<?php echo esc_url( admin_url(‘admin-post.php’) ); ?>” method=”post”> <input type=”hidden” name=”action” value=”your_action_name”> Add these in your form. Where admin-post.php will process your form. In that case based on the value of your_action_name that is provided by you, an action hook will get involved. Say for example if you add a hook like the following in … Read more

Jquery no more loading, load-scripts.php not found (404)

I had this problem with a multisite setup. On my secondary site load-scripts.php returned a 404 error. the following line in wp-config.php fixed it for me: define( ‘CONCATENATE_SCRIPTS’, false ); # worked for me my .htaccess file: # BEGIN manual WordPress Multisite # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically … Read more