Sorting custom admin column by value

Ah, the remedy was a simple one: function issue_column_orderby( $vars ) { if ( isset( $vars[‘orderby’] ) && ‘linked_issue_post’ == $vars[‘orderby’] ) { $vars = array_merge( $vars, array( ‘meta_key’ => ‘article_issue_n’, ‘orderby’ => ‘meta_value’ ) ); } return $vars; } add_filter( ‘request’, ‘issue_column_orderby’ ); I probably omitted something before…

How to change the page title from functions.php

If you refer to the post title you need to hook your function to the_title filter like explained in the codex. add_filter(‘the_title’, ‘my_custom_title’, 10, 2); If you refer to the HTML meta in your page then you need to hook your function to document_title_parts filter explained here. add_filter(‘document_title_parts’, ‘my_custom_title’, 10, 2); The two filters work … Read more

ACF Plugin – Random Gallery Image with wp_get_attachment_image()

<?php $images = get_field(‘gallery’); $size=”full”; // (thumbnail, medium, large, full or custom size) $rand = array_rand($images, 1); if( $images ): ?> <?php echo wp_get_attachment_image( $images[$rand][‘ID’], $size ); ?> <?php endif; ?> This code should work. array_rand() return key if second param set to 1 or array with keys if second param > 1

Thumbnails generated from PDF in the “Media” section – how to show them in theme template?

To get the attachment’s icon, you can use wp_get_attachment_image(). For example, let’s say I’ve uploaded a Word doc and it’s got the ID 1234: // Parameter 3 – ‘true’ – tells WP to treat this as an icon. $img_tag = wp_get_attachment_image( 1234, ‘thumbnail’, true ); // $img_tag contains: // <img width=”48″ height=”64″ // src=”http://example.com/wp-includes/images/media/document.png” // … Read more

ACF if / else checkbox [closed]

Small fix for you 🙂 <?php if( in_array( “Yes”, get_field( ‘news__item–external’ ) ) ) { ?> <a href=”https://wordpress.stackexchange.com/questions/170396/<?php echo the_field(“news__item–external-url’); ?>” class=”more icon–chev”>View full article</a> <? } else { ?> <a href=”https://wordpress.stackexchange.com/questions/170396/home.php”>Home</a> <?php } ?> The code to fix was: <php } else { <a href=”https://wordpress.stackexchange.com/questions/170396/home.php”>Home</a> } ?> You was missing the end php tag … Read more

Replace post’s “the_content” with ACF value

Instead of updating the post’s content, you can filter it using the the_content filter. add_filter( ‘the_content’, ‘wpse241388_use_acf_field’ ); function wpse241388_use_acf_field( $content ) { return get_field( ‘article_text’ ); } Update To apply to only your article post type: add_filter( ‘the_content’, ‘wpse241388_use_acf_field’ ); function wpse241388_use_acf_field( $content ) { if ( is_singular( ‘article’ ) ) { $content = … Read more

How to update custom taxonomy meta using ACF update_field() function or any other wordpress function

I figured it out somehow.. Syntax of update_field(): update_field($field_key, $value, $post_id) MY MISTAKE: I was using the wrong parameter for the $post_id which i thought was the Term Id of the custom taxonomy term. CORRECT USAGE: rather than using term id ($term_id in my question), one should use a string with the taxonomy preppended to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)