• Trying to learn WordPress to become more self sufficient from my Web Designers. On my website, I have a Side Bar that lists “Articles”. This can be seen at “www.computerpi.com/our-clients/”

    When I click any of the articles to open them, they open a new window, then open up with the PDF-PPT viewer. This whole process causes them to open very slowly. I can’t seem to find where I can change how these articles open. Ideally, I just want it so that when you click on the article name, it just opens as PDF in a new window.

    Thank you for any guidance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • If I look at the first link in the Articles widget, I see it looks like this:
    <a target="_blank" onclick="return popitup(this.href);" href="http://computerpi.com/articles/cell-phone-article/">Cell Phone Article</a>
    The “target” attribute tells the user’s browser to open the link in a new tab/window, so you already have that part, but the “onclick” attribute is running javascript that creates a pop-up window and loads “cell-phone-article,” which apparently is loading the viewer, but I’m not sure.

    If you just want to open the PDF directly in a new tab/window, I would first find the Articles widget (Appearance -> Widgets) and see what type of widget it is and how it’s set up. If you’re lucky, it’s a regular text widget that your web designer hard-coded, and you can simply remove the “onclick” part of the hyperlink and change the “href” attribute to point directly to the PDF like this:
    <a target="_blank" href="http://computerpi.com/<path to the PDF>/the-name-of-the-PDF.pdf">Cell Phone Article</a>
    replacing “<path the the PDF>” with the folder path to where the PDF is kept and “the-name-of-the-PDF” with the actual file name of the PDF.

    If you’re not lucky, the designer may have done something a bit more complicated. If that’s the case, you’ll need to take a different approach based on how the designer went about it.

    Thread Starter jskramer

    (@jskramer)

    Here is the weird part. When you look at the page itself, you see what should show up in WP as Sidebars with categories of Articles, Upcoming Events, and Rulings.

    When you go into the area that you pointed out, I can see the Sidebar, but the only thing listed in it is the Upcoming Events category. Nothing else. How can these be showing on my web page when there is nothing showing up in the theme? Heck I can’t even find where to delete the boxes and redo them fresh!

    I can see each Article in an Article tab on the left column directly under the Dashboard button, but when I go into those, I can’t seem to change the behavior. I change the linking to your recommendation, but they still open up extremely slowly from the pop up.

    What you’re describing is actually very common. I suspect that the web designer hard-coded the behavior for the widgets/sidebar into the files of the /wp-content/themes/computerpi theme they created for you. There may be a “sidebar.php” file there where the code for the widgets resides that you can edit. If you make a backup copy of the original file, you can experiment with it and revert to the original if you need to.

    From a designer’s standpoint, it’s easier to just hard-code such things into the theme rather than go to the extra effort to build the admin UI to allow user configuration of things. It saves the customer money in the short run making the initial project less expensive, though it may be more expensive in the long run because it makes the customer more dependent on the designer for changes.

    Thread Starter jskramer

    (@jskramer)

    I really appreciate your insight and assistance. In the research that I have done, it looks like the did use some sort of Widget API to create the Articles area, and then took the widget out. I suspect for the reasons you state.

    Anyway, I looked at the “sidebar.php” and it didn’t look like this held the parameters I was looking for. I then looked at “sidebar-right.php” and (in part) I see the below.

    “<div class=”width03”>
    <h4>Articles</h4>
    <div id=”rigthAreaInner”>

      <?php $the_query = new wp_query(‘category_name=Articles&posts_per_page=5’);
      while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    • <?php
      $link = get_permalink();
      $title = the_title(“”,””,FALSE);

      simple_popup_link($link,$title);

      ?>

    • <?php endwhile;

      $my_query = new WP_Query( ‘post_type=custom_articles’ );
      while ( $my_query->have_posts() ) : $my_query->the_post();
      $link = get_permalink();
      $title = the_title(“”,””,FALSE);
      echo ”

    • “;
      simple_popup_link($link,$title);
      echo “
    • “;
      endwhile;

      ?>

    </div>
    </div>”

    I see the “simple_popup_link($link,$title);” that you referred to previously, but I can’t see anywhere that it gets the link and title info from. I guess that would be in the widget that they have removed, but i would think it would still have to be getting the info from somewhere. In my Dashboard, I have a tab titled Articles where I can see the articles and I can add articles or delete them, so clearly, there must be a mechanism in there somewhere that would allow me to change their action on click, but I can’t find it anywhere.

    Having said all of that, I have discovered how to make an identical new field area that looks exactly like the Articles one for the website, and I have figured out how to set that up to do what I want. I have also found the code for the original Articles box (the one I am complaining about), so I can just delete it from the “sidebar-right.php” file and it is gone. Then I will just insert my new Articles box. Does that sound like it makes sense, or am I making things more difficult than I need?

    Thank you again for your time and guidance.

    You can certainly do as you describe, but I think there is a better method than hard-coding the widgets, mainly because the code you’re using now is looping through all the “Articles” category items so that adding a link is simple to do by just adding an article to that category, and I think retaining that functionality would be preferable.

    The line:
    simple_popup_link($link,$title);
    is actually calling the function called “simple_popup_link” from the plugin Simple Popup Plugin. I downloaded the plugin and looked at the function simple_popup_link which is in the file simple_popup_plugin.php and looks like this:

    //defines tag for theme templates
    function simple_popup_link( $templateurl, $link_text ) {
        echo "<a href='$templateurl' onclick='return popitup(this.href);' class='simple_popup_link'>$link_text</a>";
    }

    It’s telling PHP to output a hyperlink with the code you don’t want in it.

    So, what I think I’d try first is to comment out the line calling the simple_popup_link function in sidebar-right.php like this and replace it with the following line of code:

    //simple_popup_link($link,$title);
    echo '<a href="' . $link . '" target="_blank">' . $title . '</a>';

    There are a couple of things about the code I’m not sure of:

    1. It looks like there should be some formatting HTML like a break or paragraph or something after each link in the loop, but your code in the post above looks like you may not have enclosed it in backticks (or enclosed it in the “code” and “/code” buttons) so I can’t tell what should be there.
    2. I’m not sure the permalink they’re using will call the PDF directly. You’ll have to test that and see what the actual href the code comes up with looks like. I think what it’s going to do is just get rid of the pop-up and open the viewer in a new tab/window, but that will mean you’re halfway there, maybe.
    Thread Starter jskramer

    (@jskramer)

    Sorry for the delay. I really appreciate the time you have spent on this. As it turns out, the designers created a custom theme, and don’t have any of the widgets in it that were used to build it. At any rate, I find that to remove the code entirely, and just start with a new sidebar is the easiest, and gets me to my ultimate objective, which was to change the load time of the pages. I couldn’t have even figured out how to dump the old code if it wasn’t for you, so I am very grateful. Thank you very much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change How Links Operate’ is closed to new replies.