Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Tadaki1989

    (@tadaki1989)

    Thank you anyway ??

    Thread Starter Tadaki1989

    (@tadaki1989)

    Thread Starter Tadaki1989

    (@tadaki1989)

    Got it by myself; in the search.php, right before the loop, place something like this:

    <?php
    $var = $_GET['custom-field-name'];
    $posts = get_posts(array(
    	'numberposts'	=> -1,
    	'meta_key'		=> 'custom-field-name',
    	'meta_value'	=> $var
    ));
    ?>
    Thread Starter Tadaki1989

    (@tadaki1989)

    I found the solution!!
    It has something to do with the plugin “Relevanssi” I use for better search results. Relevanssi highlights the matching keywords in the post content; when these matching keywords are further below, the excerpt is “shifted”.
    So, very simple solution in the end. Thank you very much for your efforts nevertheless!! ??

    Thread Starter Tadaki1989

    (@tadaki1989)

    The problem exists also when I activate the main theme instead of the child theme.
    By checking this, I didn’t modify anything except to copy my custom search function to the functions.php of the main theme.

    Thread Starter Tadaki1989

    (@tadaki1989)

    Does anybody have a clue?

    Thread Starter Tadaki1989

    (@tadaki1989)

    is there more in the post previous to this code? If so, yes I’d like to see that too.

    I’m just getting some custom fields which are then attached to the post_title; so nothing which influences post_content.

    When I include your code, “about to do the excerpt” is attached in front of the excerpt, then followed by the three points. This is the case in both normal and “shortened” excerpts:

    about to do the excerpt
    …requirements of ISO 140012004 for the […]

    Thank you for you patience ??

    Thread Starter Tadaki1989

    (@tadaki1989)

    I don’t see the mechanism behind… sometimes the posts are quite similar, but the excerpt of only one of them is displayed the wrong way.

    This is the text editor view of a post where the excerpt is displayed the wrong way; the excerpt starts here with the words “… requirements of” etc. I replaced the rest of the document’s text with […].

    <div class="hidden">CERTIFICATE OF REGISTRATION This is to certify that XXX Inc XXX Logistics 60 South XXXX Avenue XXX Arizona 85226 USA operates an Environmental Management System which complies with the requirements of ISO 140012004 for the [...]</div>
    <div id="pdfviewer"><iframe src="https://XXX/wp-content/pdf.js/web/viewer.html?file=https://XXX/wp-content/uploads/2015/10/ISO-Certificate.pdf" width="300" height="150"></iframe></div>

    Here the text editor view of a post where it works correctly:

    <div class="hidden">ENVIRONMENTAL MANAGEMENT SYSTEM ISO 140012004 This is to certify that XXX Logistics Excellence House XXX Road XXX Business Park XXX ST5 [...]</div>
    <div id="pdfviewer"><iframe src="https://XXX/wp-content/pdf.js/web/viewer.html?file=https://XXX/wp-content/uploads/2015/10/ISO-14001-Certificate.pdf" width="300" height="150"></iframe></div>

    Do you maybe need the html codes from “further above”? These two code snippets look the same for me.

    Thread Starter Tadaki1989

    (@tadaki1989)

    No, it’s ok, thanks!

    Thread Starter Tadaki1989

    (@tadaki1989)

    Hi,

    unfortunately, it is an internal site…

    Interestingly, it does not happen to all posts of the search, only to some!
    But in all cases, three points are put in the beginning of the excerpt, even if the excerpt starts with the first word:

    “…A carbon footprint is historically defined as “the total sets of greenhouse gas emissions caused by an organization, event, product or person.” [Wright, L., Kemp, S., Williams, I. (2011)…”

    Thread Starter Tadaki1989

    (@tadaki1989)

    Hi juggledad,

    I’m using the vantage theme, but with a child theme.
    As far as I know, I did not do something with manual excerpts, so no. I once restricted the excerpt length to less words, but right now this function is commented out.

    The posts consist of an embedded pdf; before, the pdf’s text content is displayed in an invisible div to make the pdf content searchable.

    I’m also using the yarpp plugin for related posts; here, excerpts are displayed as well, and in the right way (using get_the_excerpt() ).

    If I include <?php the_excerpt(); ?> into content-single.php, the excerpt is displayed the right way as well.

    Thread Starter Tadaki1989

    (@tadaki1989)

    Just noticed that there is a mistake in line four; right would be

    'post_content' => '<div class ="XY">' . $content . '</div>',

    Thread Starter Tadaki1989

    (@tadaki1989)

    Hi davedi,

    indeed I did change the plugin files directly because I couldn’t find another way to get to the field data. So I have to include the code again everytime I update WP File Upload… not perfect but manageable.

    So what I did was changing wp-file-upload/lib/wfu_processfiles.php; right after the place when the final filename for the uploaded file is set (so right after the place in the code where it is defined what happens when a file with the same filename already exists, about line 425 or so), I put in the code lines below.

    The variable which contains the submitted user fields data is called $userdata_fields. What I basically do is using the user field data to create a post with these values. One user field defines the post’s category, another the post’s tags, another the post’s title. The posts content is created by extracting the text of uploaded pdf files by means of the ‘pdftotext’ utility ($content in my example, not shown in the code below, https://en.wikipedia.org/wiki/Pdftotext).

    $post_creation_date = current_time( mysql, 0 );
    $category_ID = get_cat_ID( $userdata_fields[1]['value'] );
    $post = array(
            'post_content'   => '<div class ="XY">' . $content . '</div>,
            'post_title'     => htmlspecialchars( $userdata_fields[0]['value'] ),
            'post_status'    => 'publish',
            'post_type'      => 'post',
            'post_author'    => 4,
            'post_date'      => $post_creation_date,
            'post_category'  => [$category_ID],
            'tags_input'     => htmlspecialchars( $userdata_fields[3]['value'])
    );  
    
    wp_insert_post( $post );
    
    }
    else {
    }
Viewing 13 replies - 1 through 13 (of 13 total)