Tag Info

Hot answers tagged

7

There is no special hook to author change. But you can achieve it by using post_updated hook. Example: add_action('post_updated', 'prefix_on_update_author', 10, 3); function prefix_on_update_author($post_ID, $post_after, $post_before) { if ($post_after->post_author != $post_before->post_author) { // author has been changed // ...


2

This solution uses the publish post hook. What's happening here is that when a post is published, it runs the custom post_published_limit function we create below. The $max_posts is set statically here, you can expand it to pull the value from elsewhere, but that's beyond the scope of the question being asked. However there is plenty of literature ...


2

The relevant code is here: query_posts("cat=25&orderby=DESCd&showposts=3&$randomArticlesNum&caller_get_posts=1"); That is the query that is pulling the posts, and that is what you want to alter. Your previous theme builder also did something that should never be done-- used query_posts(). Also, both showposts and caller_get_posts have ...


2

SOLUTION: I added $titles = array(); at the top (outside the loop). Then, within the loop, I used array_push( $titles, get_the_title( $ID ) ); to collect the titles. Then I just checked the array for a matching title before displaying, like this: if ( !in_array(get_the_title( $ID ), $titles ) ) ...then do this And it works!


2

Your logic in your code is wrong. Read your code in plain English. If the current post is number 3, show my custom content, else, show the posts as normal. What you want is the following If the current post is number 3, show my custom content. Show all my posts as normal To achieve this, you need only wrap your custom content in your ...


2

Install and activate User Meta Manager plugin. Go to Users -> User Meta Manager. Under your user click on Edit Meta. From pull down list of meta keys select edit_post_per_page and click Submit. Change the value to 10 and click on Update. All done.


1

Here is an idea but before we go into details, here are VERY VERY IMPORTANT notes NOTE: READ THIS FIRST Take a database back up before running this code. It is advisable to run this on a local install first for testing purposes. Note on wp_trash_post(), from the codex If trash is disabled, the post or page is permanently deleted. I have tested the ...


1

You can do this by checking the number of results returned by your query. Try this. <?php $rawfiltertag = get_post_meta( $post->ID, '_cmb_client_name', true ); $filtertag = sanitize_title( $rawfiltertag ); // wp_query arguments $args = array ( 'post_type' => 'post', 'meta_query' => array( array( ...


1

I found a nice way to do this using the preview_post_link filter, which allows you to rewrite the URL used by the preview operation. In my case I did something like: add_filter( 'preview_post_link', function ( $link ) { return 'http://domain.com/mobile-preview/?src=' . urlencode($link) . '%26admin_bar=false'; } ); When I click my preview button ...


1

Having so many images on one page isn't recommended. You should split the images into smaller galleries and across more than one page (or use pagination) to lower the page load speed for each page. To split a single post in several pages (adding pagination) you can just add using the text editor. Alternatively ensure you're image sizes are not too large ...



Only top voted, non community-wiki answers of a minimum length are eligible