Search WordPress Site Externally

Here’s a quick tutorial on how to perform searches against your WordPress site from another site.

To begin, add the following somewhere on your site’s page (borrowed from WordPress site):

<div id="search">
    <form role="search" method="post" id="searchform" class="searchform" action="<BLOG_SITE_URL>" onsubmit="'search_results'">
            <input type="text" value="" name="s" id="s" autocomplete="off">
            <input type="submit" id="searchsubmit" value="Search">
<p style="padding-bottom: 50px;"><p>

Where <BLOG_SITE_URL> is the URL to your WordPress site.

The onsubmit call opens the results in a new window (or tab depending on browser) named search_results. You could use _blank, but that would result in a new window every time, using a specific name uses the same window.

End result from above:

Example use:

And that’s all I have to say about that.

Posted in Geek, Programming, WordPress | Tagged , , , | Leave a comment

Listing WordPress Posts

So you have a WordPress site that hosts your blog posts along with a regular site and you want to list the blog posts on the other site, dynamically without having to manually add to the list every time you post something new. Here’s how I accomplished it.

Disclaimer: I found some of this on another site, but forgot where, so apologies for not giving credit where credit is due.

Create a posts.php page at the root of your WordPress site with the following:

<?php require('wp-blog-header.php');
<h4>::~ChrEli-BLOG~:: Posts</h4>
$args = array( 'numberposts' => 100, 'category' => 0, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$posts = get_posts( $args );

 foreach ($posts as $post) :  setup_postdata($post); ?>
        <td><a href="<?php the_permalink(); ?>" title="<?php the_title();?>" target="_blank"> <?php the_title(); ?></a></td>
        <td><?php the_date(); ?></td>
<?php endforeach; ?>

The above will produce an un-stylized output like the following:

To integrate with your other website, perform the following:

In the <head> element, add the following:

        $( "#posts" ).load( "<LINK_TO_POSTS_PHP>", function(response, status, xhr){
            if (status == "error") {
                alert(msg + xhr.status + " " + xhr.statusText);

Where <LINK_TO_POSTS_PHP> is the fully qualified link to the posts.php you created earlier.

Next, create a <div> element with the id of “posts”.

<div id="posts"><div>

If your sites are in different domains, you may get a message similar to the following in the JavaScript console:

XMLHttpRequest cannot load http://<BLOG_SITE_DOMAIN>/posts.php. No 
'Access-Control-Allow-Origin' header is present on the requested 
resource. Origin 'http://<SITE_ON_DIFFERENT_DOMAIN>' is therefore not allowed access.

Where <BLOG_SITE_DOMAIN> is the site for your WordPress blog and <SITE_ON_DIFFERENT_DOMAIN> is the site you trying to call http://<BLOG_SITE_DOMAIN>/posts.php from.

The reason for this is it is seen a a XSS (cross-site-scripting) attack. To work-around the above, add the following to the beginning of posts.php:

<?php header('Access-Control-Allow-Origin: http://<SITE_ON_DIFFERENT_DOMAIN>'); ?>

Whatever you do, DO NOT put * where http://<SITE_ON_DIFFERENT_DOMAIN> is.; that’s just asking for trouble.

The end result should look as follows:

And that’s all I have to say about that.

Posted in Geek, PHP, WordPress | Tagged , , , | Leave a comment

Xfinity X1

After repeated notifications from Comcast (Xfinity) about needing to upgrade my hardware to their overrated X1 system, I finally gave in and had them send me one. Let’s just say I wasn’t at all impressed. At first it took a while for it to adjust itself to the signal to even allow setup of the box. After that seemingly straight forward process, I [re-]setup my scheduled recordings I had on my old (reliable) Motorola DVR. Someone will have to explain to me how those could not be transferred over to the new device. From their site you can set recordings on the DVR (old or otherwise). So they knew they were there, but somehow couldn’t figure out the plebeian task of copy those scheduled recordings to a compatible format for the X1 system? Please. I digress. Once I had my recordings scheduled, I thought, “great, I’ll watch them when I get a chance;” typically that’s on the weekend. See, contrary to what Comcast would like to dictate how people spend [waste] their time, I do not sit on the couch after work for hours on end glued to the TV; I have better things to do with my time. So what I usually do is have shows recorded and watch them over the weekend. This is where X1 lost me. It’s Saturday morning and figured I’d watch NCIS which records on Tuesdays. Much to my chagrin it wasn’t in my recorded shows and I know it recorded, because on Wednesday I checked to see that it recorded. I also noticed a bunch of other shows I recorded (like “The Goldbergs”, “NCIS: Los Angeles”, etc.) throughout the week were not there. I thought to myself, that’s odd. Not thinking too much about it, I relegated myself to watching the shows on “On Demand”; with commercials of course. The main reason I record shows is so I can skip the commercials; I’m sure I’m not alone in this. Then on Sunday I decide to watch “Chicago Med”. I took note that along with “Chicago Med”, “Code Black” (yes, I like the medical dramas) was also in my recorded shows. After watching “Chicago Med” and deleting that show from my recordings, “Code Black” up and disappeared too. That pissed me off. Then it hit me: the shows disappeared from my recordings around the time they became available on “On Demand.” That was the last straw for me. I wasn’t going to continue paying Comcast over $200/mo just to watch recorded show from the broadcast networks (ABC, CBS and NBC) that I can get free with a less than $30 HD antenna. Still having the return box and shipping label for the original DVR, I packed both of them and sent them back to Comcast; cutting the proverbial cord. My HD antenna (from 1byone) gets 50 or so stations and would say they come in clearer than the box Comcast provides. Plus, if I want to catch up on shows, I can install an app (except the NBC app, I’ll get into that later) on my Pixel C tablet and cast it to my Chromecast. Yeah, I’m still stuck with commercials that way, but I’m not paying $$$ to Comcast to do that (well, except using Comcast Internet), but certainly not over $200. The NBC app by the way requires you have cable service with Comcast. That’s bullshit if you ask me. I’ve always thought the broadcast networks (already mentioned earlier) were essentially free; you shouldn’t need a cable provider to watch them.

So that’s it, that’s my short-lived experience with Comcast’s X1 system. Cut the cord folks; nobody should 1) be paying that much to watch TV and 2) do people really need 300 stations of which maybe 5 might be watched. An ala carte setup where you can pick what you want is what’s needed. With technologies like Chromecast or Amazons’ FireTV stick, the need for cable companies will no longer be justified. Almost everyone (HBO, Showtime, etc.) has an app and are offering low monthly rates to people without needing a cable providers. As for network shows, if you’re willing to wait a month or two after a season ends, it will likely wind up on Netflix (or Amazon Prime) shortly afterwards and you can watch an entire season in a weekend; without commercials!

And that’s all I have to say about that.

Posted in General | Leave a comment

Olympics: Hope Solo

I have the utmost respect for Hope Solo; for a soccer player. She’s awesome goalie for women’s soccer in the U.S. as is clear by her being the goalkeeper for the U.S. women’s national soccer team since 2000 and being a World Cup & Olympic medalist; that’s 16 years. Never one to not speak her mind, Solo pretty much says what she means and almost always means what she says; she also does not mince words. Case in point, what she said of the Swedish team after the U.S’ lost to them in the Olympics; essentially calling the them cowards. I get that she may not have liked the loss, but calling the other team “cowards” (and I realize there was a lot more said in her statement) is being a bit of a poor sport and not in keeping with the comradery that epitomizes the Olympic Games. Sometimes I think Hope needs to use her inside voice, but Hope wouldn’t be Hope if she didn’t speak her mind; raw and uncut.

And that’s all I have to say about that.

Posted in General | Tagged , , | Leave a comment

It’s Not About Guns

The tragedy that occurred in Orlando, June 12, 2016 was not about guns, it was about terrorism. Yes, the coward that perpetrated this act was apparently able to buy an AR-15 assault riffle without issue. However, up to that point, he had not broken any laws nor had he been convicted of any crimes and, again, at that time, was not on a watch list. He was on a watch list in 2014 (for the second time; twice as much as 99.999% of the rest of the population), but when he obtained his weapons of destruction, he was not. And even if he was, that would not precluded him from purchasing a gun; there apparently is not tie between the background check (if you can call it that) and a terror watch list and/or no-fly list. Should there be? Yes. Would it have prevented what occurred on this past Sunday? Sadly, no. The assailant had planned this for a while (just ask his wife) and would have found another way.

This was about an weak-minded, brainwashed coward who had known ties to an equally cowardly terrorist group and connection with the U.S. suicide bomber in Syria. He also had a bit of hero-worship with Boston Marathon bombers.

I get that certain religions (Islam is not alone) may have objections to some people’s proclivities or different beliefs, but that does not give them the freedom to assassinate innocent people because of that. People are different, think differently, have different opinions, beliefs and are not always going to agree with everyone elses; just deal with that and move on.

And that’s all I have to say about that.

Posted in General | Leave a comment