Audio post format with Advanced Custom Fields

Advanced Custom Field plugin uses get_field() to retrieve values. Your code should be something like: $audio = get_field(‘audio_post_format_url’, $post->ID); var_dump( $audio ); # To make sure you’re retrieving the right value echo wp_oembed_get( $audio ); Note that get_field() does not need a second parameter, it will take the current post ID if omitted. If var_dump( … Read more

Retrieve post in AJAX Callback

It’s possible to capture the $post_id using a combination of wp_get_referer() and url_to_postid() then reset the $post using setup_postdata. That should work easy enough for the front-end. But on the admin side we’ll need to pull the query with parse_url and grab the ID using parse_str. For good measure we should double check if we’re … Read more

How to have one page show posts reverse-chronologically, but the others chronologically?

You want a filter on pre_get_posts restricted to the home page. Something like: function pregp_wpse_214875($qry) { if (is_home() && $qry->is_main_query()) { $qry->set(‘order’,’ASC’); } } add_action(‘pre_get_posts’,’pregp_wpse_214875′); You may need something other than is_home(), depending on how your “home page” is set up. The other most likely option would be is_front_page()

Get total post from an author

the_author_posts() doesn’t accept any parameters see the following codex page for more info: https://codex.wordpress.org/Function_Reference/the_author_posts#Parameters * UPDATED * Someone else had posted a VERY similar question. This should solve your problem: Show author post count in sidebar – Variable

Split post title for styling

Will the format always be as you described? I.e. can we use ‘x’ as a delimiter to split your title? If so something like this would work: add_filter( ‘the_title’, ‘wp123_custom_title_format’, 10, 2 ); function wp123_custom_title_format( $title ) { // if you only want to modify certain posts you can do a check here // use … Read more

Conflict array_splice on loop and query in widget

Your code is quite messy which makes debugging hard, so I cleaned up your code a bit. The posts_results filter accepts two parameters, one being the posts results array, and the second one is the current WP_Query instance. So you can pass the second argument and then test for your conditions. I haven’t tested your … Read more

Auto update post title and slug when post status is changed

I think I found the solution: add_filter(‘wp_insert_post_data’,’reset_post_date’,99,2); function reset_post_date($data,$postarr) { //update post time on status change $data[‘post_date’] = $data[‘post_modified’]; $data[‘post_date_gmt’] = $data[‘post_modified_gmt’]; //also update title and add the current date to title $data[‘post_title’] = ‘Your Default Title – ‘. current_time ( ‘m-d-Y’ ); //also update the slug of the post for the URL $data[‘post_name’] = … Read more

Add “Posted on” to post date

The post date is added by twentyfourteen_posted_on as shown in content.php. This function is in /inc/template-tags.php and is correctly wrapped in an if ( ! function_exists( ‘twentyfourteen_posted_on’ ) ) conditional so you can declare the same function in your child theme and modify it to your heart’s content. As such you could add a function … Read more

add div after image in post [closed]

Your question is a little light on detail of what you want to happen precisely. In general anything in WordPress content is usually treated as such. It’s not very friendly to being mixed with code, although many solutions try (often with poor results). The basic approach would be to use the_content filter to process post … Read more