Support

Account

Forum Replies Created

  • Hi Elliot,

    Thanks for your response! Basically the site deals with books. Previously authors were a separate post type and were attached to books via a relationship picker. Something went wrong with the permalinks which I’ve been unable to fix which means that I’ve now moved the author information onto the books pages. However, the information about the author(s) (e.g.: bio) is still saved as a separate post type.

    The issue is that you can’t search by author name and bring up the relevant books, I presume because, unlike other text fields for example, the relationship picker present different information.

    Do you know of a way to force Relevanssi (which I’m using in order to factor in various ACF custom fields) to search the post titles (in this case author names) selected in the relationship field rather than the numerical IDs assigned?

    Thanks very much!

  • Thanks Jonathan — and for tidying it up, that’s much appreciated. The markup is terribly messy at the moment and that’s one of the reasons I’m revisiting it now as I know a little more now than I did when this was put together.

    I didn’t include the radio button snippet as much of the code on the page will be changing over the coming weeks (I don’t envisage this causing a problem), but it will be going, with some other stuff, in place of the ‘details binding’ section that appears at present.

    Thanks

  • OK, here it is — I’ve tried many different configurations and nothing works so something is clashing I guess.

    Be warned, this code is probably very messy — it’s a couple of years old, hence why I’m revisiting it now to tidy it up!

    Code

  • Silly me. Wrapped as follows:

    <?php print_r(get_field('stock')); ?>

    …it doesn’t change anything on the page at all.

  • Simply outputs that into the page:

    print_r(get_field('stock'));

  • Thanks Jonathan, that seems logical but unfortunately it’s just crashing the site (white screen).

  • I have radio buttons set up with three options:

    Forthcoming
    In Stock
    Out of Stock

    These are set up to run on a custom post type, ‘Book’

    I want to output something different depending on which option is checked.

    This all takes place within the loop.

    I don’t have any code relevant to the issue to show I’m afraid. I had previously used a single checkbox and called it as follows:

    <?php if ( get_post_meta($post->ID, 'paperback', true) ) : ?>
    	Paperback
    <?php endif; ?>

    This worked fine, but I don’t know how to query the custom field AND the option selected, which is the problem here.

    I hope that’s a bit more clear, sorry I can’t provide more!

  • Thanks both — after reading Jonathan’s comment, I realise that radio buttons are actually better in this case as the user will only be checking one option.

    I’ve tried both the pieces of code suggested and neither outputs anything.

  • OK, it comes out looking like this:

    Screengrab

  • Thanks, Roberto. By using the following code (pasting it to check I’ve got it right), I see no change — it’s not showing anything for this particular field.

    <?php
    if ( in_array( 'in_stock', get_field('stock') ) ) 
    { ?>   echo '<pre>';
    var_dump(get_field('stock'));
    echo '</pre>';
    <?php } ?>
Viewing 10 posts - 1 through 10 (of 10 total)