• ryanlavine

    (@ryanlavine)


    Please forgive me if this has already been addressed; I was unable to find anything using the search equal or similar “text only.” Because I am a beginner, this may have been addressed in a more technical language than I am familiar with; I do not yet understand what ‘attributes,’ ‘elements,’ ‘class,’ ‘ID,’ or ‘targets’ are or how they work.

    If I have a page or post with various elements such as text blocks, images, buttons, spacers, icons, etc… is it possible to write a short code to print “text only” from the body of a page (or any specific or set of specific elements, for example “text & star rating only”)?

    Thank you in advance for your replies.

    This is a fantastic plugin!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor twinpictures

    (@twinpictures)

    Do you have a link to the page in question? This way we can use descriptions that are less technical and maybe easier to follow for those playing along at home.

    Thread Starter ryanlavine

    (@ryanlavine)

    Here is a model page, using Elementor as the builder:

    https://varsityed.com/print-o-matic-test-page/

    Plugin Contributor twinpictures

    (@twinpictures)

    OK. So there is no magical ‘text only’ feature. But you can try and target all of the elements that contain text in them on that page, namely:
    H1, H2, P, LI elements.

    Following so far? If so, let’s move on.

    To target these elements for print, simply place the shortcode using the following target attribute like so:

    [print-me target="h1, h2, p, li"/]

    Give that a try and see if it helps you understand the basic concept of elements and shortcode attributes.

    • This reply was modified 2 years ago by twinpictures. Reason: added links to documentation
    Thread Starter ryanlavine

    (@ryanlavine)

    Okay! So I did as instructed, and it works very well! Thank you! (it prints the WP toolbar, but I opened in incognito and that disappeared.)

    • It is printing the elements, including any empty space within that element, so any empty space within the printed page would be eliminated by formatting the webpage, correct?
    • Is there a list of element attributes? (I am assuming an element attribute is paragraph = p. Is this correct?
    • What are ‘class,’ & ‘ID’?

    Again, thank you for your teaching, here!

    Thread Starter ryanlavine

    (@ryanlavine)

    One more inquiry:

    If I would like to print H5P content, (or perhaps any other plugin’s content), how might I identify the element attribute for it?

    E.g. – I have an H5P “column” element on the example test page. If I wanted to print it, what would I include in the command?

    Thread Starter ryanlavine

    (@ryanlavine)

    Playing around with this awesome plugin using Elementor Pro, I wanted to inquire as to how I might identify different element’s/widget’s HTML element code such as ‘p’ or ‘h2’ for something like an image, a list, an icon, a counter, etc. Or, for those, do I need to add a CSS ID / CSS CLASS?

    …and IF I add a CSS ID, can I add the same ID to every element I want to print (e.g. CSS ID = ‘print’)?

    ***

    How can I find which component of the page is printing unwanted material? E.g. – while using …

    [print-me alt=”Click icon to print this section” target=”body,h2,p”/],

    …in the middle of each of the three pages (same place on each page) and over other content, there is a command phrase, “Enter the destination URL or link to existing content.”

    Viewed sources:

    https://pluginoven.com/plugins/print-o-matic/documentation/shortcode/

    https://pluginoven.com/plugins/print-o-matic/documentation/shortcode/#target-attribute

    Plugin Contributor twinpictures

    (@twinpictures)

    HTML element code?such as?‘p’?or?‘h2’?for something like an image, a list, an icon, a counter, etc. Or, for those, do I need to add a?CSS ID?/?CSS CLASS?

    You can use P or H2, but it’s smarter to identify a wrapping container that holds the elements you want to print and assign an ID or a CLASS.

    …and?IF?I add a?CSS ID, can I add the same ID to every element I want to print (e.g. CSS ID = ‘print’)?

    You are only allowed to assign a Unique ID to a single element on a page. If you want to target multiple elements, best to assign them the same CLASS, which is allowed to be assigned to multiple elements on the same page. So for example prove the class of ‘print’ and then target them using ‘.print’ (the dot before the class name tells the system to look for a class)

    How can I find which component of the page is printing unwanted material? E.g. – while using …

    [print-me alt=”Click icon to print this section” target=”body,h2,p”/],

    If you are targeting the body element, then that contains everything on the page… so that’s probably what is causing unwanted info to print. Remove the body element from the target.

    Probably best to open your own thread on that last issue and be sure to include a link to the page in question.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to Print Text Only’ is closed to new replies.