Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
jink
May 8, 2002

Drop it like it's Hot.
Taco Defender
How do you recommend including custom javascript?

I understand WordPress has built in library loading, how do you link to custom javascript 'correctly'? A designer and I had trouble getting a clear answer to this via google, so we put the custom javascript in the root of his site and linked to the javascript in his skin to the root. Not optimal, but it worked. Is there an official way?

Adbot
ADBOT LOVES YOU

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender
Thank you for the wonderful replies! You have answered my questions expertly. This thread is making me contemplate using WordPress on my site. I've been wary of it due to what seemed like a complicated structure.

Ned posted:

I learned this a couple of weeks ago. The answer is wp_enqueue_script(). Usually you want to associate the script with the theme so put it somewhere inside the theme directory. I use /js for my javascript files.
code:
wp_enqueue_script('jquery');
wp_enqueue_script('ew_blogjs', get_bloginfo('stylesheet_directory') . '/js/blog.js', array('jquery'), '' );
I saw this method before. We tried to use it, but WordPress refused to load the javascript. I assume /js/ is a folder inside your theme?

Do you have any links to wordpress sites you have created? I would love to see what you have come up with. The designer I worked with has this WP Blog: Visual Craftsman (Regular Site)

supster posted:

It's actually best practice to include Javascript at the end of your body when possible so I tend to avoid the wp_enqueue_script method and just manually put a script tag at the end of the body using something like the following.
code:
<script type="text/javascript" src="<?= get_bloginfo('template_url') ?>/js/my_js.js"></script>

I agree with this 100%. I have been reading a ton on YUI best practices. Not only am I completely bonkers for minifying javascript, I am also a big proponent for putting javascript at the bottom.

I understand that 'enque' is recommended since it reduces conflicts by using a 'name'. Would there be a case of duplicate javascript running when manually inserting it at the bottom of a theme? I don't think you can nest a theme inside a theme? (not sure why this could cause conflicts)

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

Ned posted:

Yeah, /js/ exists inside of my theme. It is a fun folder!
Indeed, this is where we messed up. I couldn't get WP to see it correctly. I am not sure how I could have messed something like that up though.

Ned posted:

Currently I am setting up 10 blogs for ew.com - 2 of them are new and 8 are migrations from typepad.com. Because Time Inc doesn't have any internal PHP servers they are using wordpress.com hosting. These launch in a couple of weeks but you can see the main site we are testing at http://ewwatchingtv.wordpress.com/

I've probably done about 50 Wordpress sites now. I set them up at BET.com and then maintained and modified the blogs for mtv.com for a while. I also built a series of 12 blogs for a project for P&G called swaggerizeme.com which got people to fill out a form on a flash site and then it would create fake blog posts to fill up those 12 blogs and it would buy a google ad in that person's name and then point the ad to one of the blog posts.

I just launched moulicohen.com and I have two more sites I am currently working on. I also built This is Historic Times for Deep Hurting and a site for a wallpaper designer named Aimee Wilder. Aimee Wilder is kind of a neat site because it has a traditional blog in there with a different style from the pages that we use to show off her work.

Incredible sites man, I love the look of every one of them! You do great work. :)

Ned posted:

Personally I'm not a fan of putting javascript at the bottom of a page. While I can see benefits to doing it in terms of pure speed I just doubt it makes enough of a difference to require a different development paradigm. I like the idea of looking at the head to see all the goodies in a page. A lot of the sites I do are stuck using document.write in the middle of the page anyway for ads so that is going to be the true bottleneck.

I just found a WordPress javascript/css minifyer: http://omninoggin.com/projects/wordpress-plugins/wp-minify-wordpress-plugin/ It finds all js/css files in the head and joins and minifies. This is the best of all worlds, and wonderful for me!


You have convinced me to try out WordPress. I have it installed and am creating a theme. It was incredibly easy to install. The plugins are ample, and I am loving how everything works so far. Once I get further along I'll post a link.

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

Guy LeDouche posted:

My WordPress effort https://www.thefragfile.com in less than 2 days, with some generous help from Ned.

Wow! Great looking site, good amount of content. I love the columns.

I am not sure the colors match up to the 'frag file', I didn't think about video games or fragging when I saw it. I thought of peaceful blogging. :D

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

VeryVito posted:

Here's a good response to this question -- a white paper written by a major PBS affiliate on how they launch 5-10 high-quality sites each month using a single WP interface as the CMS.

This blew my mind. The company I work for is investigating how to do this with Drupal. I am wondering if WordPress would be a better solution, especially with WordPress MU.

Kitsch Ersatz posted:

Is it possible to upload a bunch of images via FTP instead of using the individual upload media interface within the post page? I tried with no luck (Wordpress not detecting images in the "gallery").

Would the Add From Server plugin help you? It claims to "allow you to browse the filesystem on the webserver and copy any files into the WordPress uploads system".

jink fucked around with this message at 00:26 on Jul 18, 2009

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

atastypie posted:

Is there a plugin that combines the javascript/css that all the other wordpress plugins install, so that there is only a single request for them? I hate it when a plugin includes the css inline below the header or when plugin javascript is loaded at the top of the page, instead of the bottom :(

You can check out WP Minify, which will join all JS into one file and minify the contents. The plugin also joins CSS.

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender
Is there a way in WordPress to detect if a page ID is the static homepage ID?

I am creating nav/footer based on the page & sub page hierarchy but the homepage does not need to show up in these lists.

I know of the is_front_page() function but that only tells me if the currently displayed page is the front page, not if an arbitrary page ID is the home page.

php:
<?php 
$pages get_pages(array('sort_column'=>'menu_order'));
$count count($pages);

for ($i=0;$i<$count;$i++)
{                    
    $item get_page($pages[$i]);
    /* would love to act differently here if $item->ID == get_front_page_id(); ! */
}
?>

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

Twiin posted:

I'm not sure exactly what you're doing, but maybe the Exclude Pages plugin might work for you?

That works perfectly and will work with what I am trying to accomplish:


I am setting up a site that uses WordPress as a CMS. Pages are the only thing we will be using on the site, no posts.

The front page has special handling to make it into a gallery (detected in page.php). This page doesn't need to show up in any nav as there is a graphical link in the nav that directs to the blog homepage. I was trying to prevent my nav from duplicating the front page link when calling get_posts, but was unable to detect if a given page returned was the front_page.

Thank you very much, this plugin will be an excellent stopgap.

SuckerPunched posted:

get_pages has an exclude option you can pass to it.

http://codex.wordpress.org/Function_Reference/get_pages#Parameters

I saw, but I don't know the front page's ID beforehand. :( I didn't see a way to pull this ID information out using other means, did I miss something?

Adbot
ADBOT LOVES YOU

jink
May 8, 2002

Drop it like it's Hot.
Taco Defender

Charlie Thunder posted:

How do I make it so the front page is the entire most recent post?

Create a new template for your front page. The template needs to include the header/footer calls and include something similar to this 'loop' setup that grabs the latest single post and outputs it's title and content:

php:
<?php query_posts(array(
                  'orderby'=>'date',
                  'order'=>'DESC',
                  'posts_per_page'=>1));
       while(have_posts()):the_post();?>

<h1><?php the_title();?></h1>
<?php the_content();?>

<?php endwhile; ?>

Once you are happy with the template, create a new page using that page template and then set up your front page (under settings->reading) to that new page. WordPress should then output the latest post in it's entirety when going to the front page.

Charlie Thunder posted:

And in the menu there is a link that goes to what would typically be the front page (title/summary for the last 10 posts).

I have no clue what you mean here?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply