getting a server error now – maybe just timing out:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Thank you John – very much appreciated – I still have to learn a lot.
Here you go – I had to comment the meta query in order to have the default search returning any results?
function themeprefix_include_custom_post_types_in_search_results( $query ) {
if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) {
$query->set( 'post_type', array( 'post', 'case', 'client', 'event', 'job', 'opportunity', 'partner', 'team' ) );
/*
$query->set( 'meta_query', array (
'relation' => 'OR',
array (
'relation' => 'AND',
array (
'key' => 'job_status',
'compare' => 'EXISTS'
),
array(
'key' => 'job_status',
'value' => '1',
'compare' => '=',
'type' => 'NUMERIC'
),
),
array (
'relation' => 'AND',
array (
'key' => 'opportunity_status',
'compare' => 'EXISTS'
),
array(
'key' => 'opportunity_status',
'value' => '1',
'compare' => '=',
'type' => 'NUMERIC'
),
)
) );
*/
}
}
add_action( 'pre_get_posts', 'themeprefix_include_custom_post_types_in_search_results' );
@John – when setting the meta query I’m not getting any search results of search terms in pages – how do I get around that?
Thanks David – what I did not knew/considered that the WP search does not search my custom fields – so we are able to add the post types to the search but not the custom fields it seems.
Thank you John – that somewhat got me going – what I did NOT considered/knew at all is that the custom fields are not searched at all so I’m not really sure where I will go from here.
Thanks for your link – I’ll give it a try.
Hello John
thanks for replying – I’ve seen in another thread you mentioned that before and I tried it but it didn’t work for me whereas the plugin I mentioned actually works
That did the trick – thank you James!
Thank you James
I’m sure your solution is more advanced – I came up with `if ( strpos( get_field( ‘resource_media’ ), ‘.mp3’ ) )
echo do_shortcode( get_field( ‘resource_media’ ) );`
I did the trick as well.
that did the trick – thank you Joe.
I’m trying to do exactly the same – it’s a pity that the taxonomy field doesn’t provide conditional logic.
Thanks for replying Joe
actually getting the taxonomy terms isn’t the issue – what I’m trying to do is basically simulating the “taxonomy” field using a select field – the reasons for that is that unfortunately the “taxonomy field” doesn’t allow for conditions later on whereas the select field does. I can easily get the terms of the taxonomy and populate the select field but how do I pre-select the terms assigned already to the post when populating the select field – any ideas?
Hello
this might be related – I’m trying to populate the default value of a dynamically populated select field – I cannot get it to display the default value – hope somebody can help.
// Populate the category select field with dynamic values
add_filter( 'acf/load_field/name=resource_category', 'prefix_acf_load_resource_category_field' );
function prefix_acf_load_resource_category_field( $field ) {
// reset choices and defaults
$field[ 'choices' ] = array();
$field[ 'default_value' ] = array();
$terms = get_terms( 'resource_category', array( 'hide_empty' => false ) );
foreach ( $terms as $term ) {
$field[ 'choices' ][ $term->slug ] = $term->name;
if ( has_term( $term->slug, 'resource_category', get_the_ID() ) )
$field[ 'default_value' ][] = $term->slug;
}
return $field;
};
thanks James but it doesn’t work – interestingly the following does work:
$args = array(
'post_type' => 'ze_knowledge',
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page' => '-1',
'meta_key' => 'knowledge_video',
'meta_value' => ' ',
'meta_compare' => '!=',
);
got the same issue
put 5.2.8 back and everything works as expected – am I doing something wrong or is there an issue??
not working – I echoed the id – id is certainly correct.
I thought the third paramenter in get_field is for the format – nevertheless, plain get_field(‘fld_teaser_content’) doesn’t return anything either whereas get_post_meta always returns the correct value?
this is the whole function – hope it helps:
add_filter( 'genesis_before_entry_content', 'custom_entry_content' );
function custom_entry_content() {
if ( !is_single() )
return;
$id = get_the_ID();
if ( empty($id) )
return;
$teaser_content = get_post_meta( $id, 'fld_teaser_content', true );
//$teaser_content = get_field( 'fld_teaser_content', $id, true );
if ( empty( $teaser_content ) )
return;
$html = "\n\t" . '<div class="teaser-box neutral-box">';
$html .= "\n\t\t" . '<div class="teaser-header"><h6><i class="icon-pushpin pull-right"></i>Hinweis</h6></div>';
$html .= "\n\t\t" . '<div class="teaser-content">' . sanitize_text_field( $teaser_content ) . '</div>';
$html .= "\n\t\t" . '<div class="teaser-footer">Bitte <a href="?page_id=38" title="Kontakt">kontaktieren</a> Sie uns für ein unverbindliches Gespräch.</div>';
$html .= "\n\t" .'</div>';
echo $html;
}
something weird is going on here:
//$teaser_content = get_post_meta( $id, 'fld_teaser_content', true );
$teaser_content = get_field( 'fld_teaser_content', $id, true );
the first disabled line of code actually returns the content of the field – however links are not showing as links
the second line of code doesn’t return the field content
Hope you got an idea?
What am I missing
Thanks for replying Elliot – actually this is not about converting links to tags – this is about entering plain html code incl. a tags like <a href=…. that do not appear as links in the front-end also I’ve entered the html code properly?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.