Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter goldenatlas

    (@goldenatlas)

    Nice! That worked perfectly! Here’s how I added my own blend of custom fields to Relevanssi:

    function add_custom_fields_to_relevanssi($post) {
      /*
       * Do stuff here with the $post object to get your custom field data.
       * Convert any terms inside of arrays or serialized objects into a
       * string at this time, i.e.:
       *
       * $custom_fields = array (
       *   [browsers] => array('chrome', 'safari'),
       *   [providers] => array('google', 'yahoo'),
       * );
       *
       * should be converted to:
       *
       * $custom_fields = "chrome, safari, google, yahoo"
       */
    
      // Add your custom field data to $content
      $content .= " " . $custom_fields;
    
      // Return the content
      return $content;
    }
    add_filter('relevanssi_content_to_index', 'add_custom_fields_to_relevanssi', 10, 3);
    Thread Starter goldenatlas

    (@goldenatlas)

    OK, here’s how I found to get text inserted at the bottom of a post, but I don’t understand how this function figures out WHERE to put the content…how do I tell it to place it at the top?

    <?php
    // add custom post content
    add_filter('the_content', 'add_post_content');
    function add_post_content($content) {
    $content .= '<p class=pre-title>Today’s Episode</p>';
    return $content;
    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)