The editor is set to accept the HTML code only and if you enter the PHP code, it will be commented out by the editor. If you want to get some custom output that you need to control using PHP, you can try adding a new attribute to accept a shortcode and then add the shortcode to the field when you insert the element to your page. This way you can control the output by that shortcode and use your custom PHP. I haven't tested this, but it should work fine. Or you can use the dynamic field option as well.
Published in Blog
Sunday, 02 May 2021 07:20

ACF Link in repeater field


<?php if( have_rows('call_to_actions') ): ?>
<?php while( have_rows('call_to_actions') ): the_row();
?>
<?php
$link = get_sub_field('button');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target'] ? $link['target'] : '_self';
?>
<div class="btn-wrap">
<a class="btn btn-primary scoli-primary-btn" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?> <i class="material-icons">arrow_forward</i></a>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>

Published in Blog

/**
* Removes buttons from the second row (kitchen sink) of the tiny mce editor
*
* @link http://thestizmedia.com/remove-buttons-items-wordpress-tinymce-editor/
*
* @param array $buttons The default array of buttons in the kitchen sink
* @return array The updated array of buttons that exludes some items
*/
add_filter('mce_buttons_2', 'jivedig_remove_tiny_mce_buttons_from_kitchen_sink');
function jivedig_remove_tiny_mce_buttons_from_kitchen_sink($buttons)
{

$remove_buttons = array(
// 'formatselect',
// 'underline',
// 'alignjustify',
'forecolor',
// 'pastetext',
// 'removeformat',
// 'charmap',
// 'outdent',
// 'indent',
// 'undo',
// 'redo',
// 'wp_help',
);
foreach ($buttons as $button_key => $button_value) {
if (in_array($button_value, $remove_buttons)) {
unset($buttons[$button_key]);
}
}
return $buttons;
}

Published in Blog

Here is an example where I have created a custom post type called faq_categories.
in the settings for the custom post type, ensure the following is set to true:

  • Hierarchial
  • Rewrite Hierarchial

<?php

$args = array(
'post_type'=>array('faq', 'faqs'),
'taxonomy' => 'faq_categories',
'faq_categories' => 'patient'
);

query_posts($args);



if ( have_posts() ) : ?>

<!-- do something -->

<?php endif;

wp_reset_query()

?>
Published in Blog
Wednesday, 29 July 2020 05:17

Linkedin not respecting open-graph tags

I had an issue with the LinkedIn post inspector displaying the words footer-text within the snippet. It turns out that the og:title was not respected at LinkedIn. The problem was WordPress itself - not LinkedIn.

Disable the WP Rest API, and you are good to go. The contents of the oembed+json link that is embedded in the wp_head() creates the issue with the "title" being set to "id".

 

I achieved this by installing the Disable WP Rest API plugin for WordPress. This solved the problem and Linkedin displayed the posts as expected.

Published in Blog

<?php
wp_nav_menu( array(
'menu_class' => 'kt-nav main-menu clone-main-menu',
'container' => '',
'items_wrap' => '<ul class="%2$s">%3$s</ul>'
) );
?>

Published in Blog
Thursday, 21 May 2020 12:16

Create a loop for custom post types

<?php

// Define custom query parameters
$custom_query_args = array(
/* Parameters go here */
'posts_per_page' => 12,
'post_type' => 'video_production',
);

// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );

// Pagination fix
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $custom_query;

// Output custom query loop
if ( $custom_query->have_posts() ) :
while ( $custom_query->have_posts() ) :
$custom_query->the_post(); ?>

Do stuff here

<?php
endwhile;
endif;
// Reset postdata
wp_reset_postdata();

// Custom query loop pagination
previous_posts_link( 'Older Posts' );
next_posts_link( 'Newer Posts', $custom_query->max_num_pages );

// Reset main query object
$wp_query = NULL;
$wp_query = $temp_query;

?>
Published in Blog

Place this in your theme’s functions.php file.


/*-------------------------------------
Move Yoast to the Bottom
---------------------------------------*/
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');

Published in Blog
Saturday, 16 November 2019 02:36

Echo custom taxonomy values


<?php
$terms = get_the_terms( get_the_ID(), 'bake-lovers-categories' );
if ($terms) {
foreach($terms as $term) {
echo '<span class="tag">'.$term->name . ' '.'</span>';
}
}
?>

Published in Blog
    
<?php
$aust1 = types_render_field("available-in-australia", array("option"=>0));
if ($aust1) {
echo 'woolies';
}
$aust2 = types_render_field("available-in-australia", array("option"=>1));
if ($aust2) {
echo 'coles';
}
$aust3 = types_render_field("available-in-australia", array("option"=>2));
if ($aust3) {
echo 'other';
}
?>

Published in Blog
Page 1 of 5