Forum Replies Created

Viewing 15 replies - 46 through 60 (of 62 total)
  • It looks like PHP is working, or your login page wouldn’t come up (which it does).

    The redirect is actually getting to WordPress. You can test this by going to an individual page, like so:

    http://geoffdigital.com/?p=4

    Note that it redirects to the correct page (if you try and go to a non-existent page, it will give you an error).

    Since you can get to the login, the simplest thing to do is see if you can re-set your permalinks. Just choose another option and save, and see if they work. If so, try changing them back, and saving again.

    If that doesn’t do it, you may want to try disabling your plugins. All of them. If that fixes it, re-enable them, one at a time, and see if they start working again, noting when the permalinks start functioning again.

    Finally, you could always try using another theme. Doubt this is it, but it’s something worth a shot if nothing else helps.

    One note – this is on the individual post page, not the main index page. To add it there, you’ll need to update another template.

    The main index template is called index.php and the process is generally the same – you’ll just need to add that to your child them, and repeat it in that template as well. Probably best to get it down first, however. 🙂

    Scroll to the bottom of the page. 🙂

    If you don’t want it there, you’ll need to move it.

    If you look at the code, you see:

    – the php for the content

    – a nav class for the navigation

    – the php for the comments template

    – the links

    Just put them where you want them. For instance, if you want them right after the article, put them directly after this php:

    <?php get_template_part( 'content', get_post_format() ); ?>

    And before the start of the nav for the navigation.

    Other than that, good job!

    Just use page templates.

    If they are really very similar, you might be able to do with the same template, or if you have, say, 20 that use one layout, 20 that use another, and three that use a third template, then you could have three templates, and those are the only ones you need. You could do it with 43 separate templates, but that would be a lot of work, and I would think is fairly unusual, especially if the pages look exactly the same.

    When you go to create your page, you give it a title, select the template, upload the image, create the text, save it, and you’re done.

    You may choose to change the order in which you complete the information – I just listed it as it came to me.

    DNS may be okay – but really all that means is that Bluehost is processing the request with a wildcard. Try and request “tiffany.petgroomingtemplate.com” and you’ll see that it will work (put any word you like and it will go through fine – but you’ll end up at the root domain). That means the problem is likely in the setup.

    For example…

    This site:
    http://testingsite.petgroomingtemplate.com/

    Ends up here:
    http://petgroomingtemplate.com/wp-signup.php?new=testingsite

    Not entirely unexpected, but certainly not what you would expect.

    This site:
    http://newtestingsite.petgroomingtemplate.com/

    Goes here:
    http://petgroomingtemplate.com/

    The good news (such as it is) is that this one works:
    http://2489268841lilnells.petgroomingtemplate.com/

    So that means it is likely the configuration, more than likely these lines:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', '');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    MULTISITE has to be true. SUBDOMAIN_INSTALL, could go either way. DOMAIN_CURRENT_SITE, probably ‘petgroomingtemplate.com’. PATH_CURRENT_SITE, depends on where your current site is installed. Possibly ‘/wp/’. The CURRENT_SITE values are probably both 1, but you never know.

    I would specifically look at the DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE.

    Bluehost should provide access to the database with phpMyAdmin – you could look at the sites there to see if you have data in the database. If so, you really only need to get it pointed correctly at the right place and they will come back up.

    Still not really sure what you’re after, so knowing exactly what you’re trying to produce could be helpful. 🙂

    The link to get_the_category may be where you want to spend some time.

    The code above is only going to match on the first category assigned to your post – that’s the [0], an index to the category array for the post. And yes, an index of 0 pointing to the first item doesn’t really make sense. It’s just the way it works – not just in PHP, but in many programming languages.

    So if the problem is that your posts will (potentially) have many categories, then perhaps you should loop through all of them, which would instead look more like this:

    <?php
    foreach((get_the_category()) as $category) {
    if ( $category->cat_name == 'FOOTBALL' ) {
       echo "hello world";
    }
    }
    ?>

    The get_the_category actually returns an array, but rather than looking at only the first item (see, ma, no index!), it’s looping through them (foreach) instead. So if any one of them matches FOOTBALL, it’s going to echo ‘hello world’. This means no matter when FOOTBALL was added, it’ll show.

    Before, if SOCCER (or HOCKEY, or any other category) was added, and FOOTBALL was added later, so that it wasn’t the first one, then it wouldn’t match $category[0]. Thus, it wouldn’t work.*

    Now, if you want to match multiple conditions, it’s going to get a little more complex.

    <?php
    foreach((get_the_category()) as $category) {
    if ( $category->cat_name == 'FOOTBALL' || 'HOCKEY' ) {
       echo "hello world";
    }
    }
    ?>

    That’s FOOTBALL or HOCKEY.

    <?php
    foreach((get_the_category()) as $category) {
    if ( $category->cat_name == 'FOOTBALL' || 'SOCCER' ) {
       echo "hello world";
    }
    }
    ?>

    That’s FOOTBALL or SOCCER.

    <?php
    foreach((get_the_category()) as $category) {
    if ( $category->cat_name == 'FOOTBALL' || 'HOCKEY' || 'SOCCER' ) {
       echo "hello world";
    }
    }
    ?>

    That’s FOOTBALL or HOCKEY or SOCCER.

    <?php
    foreach((get_the_category()) as $category) {
    if ( $category->cat_name == 'FOOTBALL' && 'HOCKEY' ) {
       echo "hello world";
    }
    }
    ?>

    That’s FOOTBALL and HOCKEY. Don’t do that – because you’re only looking at one category at a time, so you’ll never get a match.

    * So you could also change the index – looking for $category[1] or something. But that just changes your problem. You would then be looking for FOOTBALL in the second category assigned (index 1 is the second item, just as index 0 is the first item). So I don’t think it’s going to help.

    Let me know if this does it for you.

    Something like this perhaps?

    <?php
    $category = get_the_category();
    if ( $category[0]->cat_name == 'FOOTBALL' || 'SOCCER' ) {
       echo "hello world";
    }
    ?>

    This sounds very similar to your other request, which has a rather detailed response (from me :).

    This seems simple, and in reality it’s not that difficult, but actually describing how to do it is going to seem more difficult (meaning longer) than it is, to make sure we hit all the steps. Sorry if you know some of them, but I wanted to address everything, in case you needed anything along the way.

    First, you have the child theme. Make sure you understand this, because it’s important. In short, the child theme overrides the templates from the parent theme. All the child theme needs to exist is a style sheet, and you may only have a style sheet, so the first step is to make sure that you have a single.php template in the child theme – this is so that you don’t make changes to Twenty Twelve itself.

    If you currently have a copy of single.php in the child theme, you may want to make a copy of it – either by making a copy of the entire theme, or by backing up that file itself.

    If you don’t have a copy of single.php, then just copy it from the parent. This is probably ideal, because then if something goes amiss, you can just copy another one – it’s like you have a built-in backup!

    The most important thing to do is make sure that this template is in the Twenty Twelve Child directory (twentytwelve-child). With that done, you can make changes to that template to add your text links.

    Now you need to decide where to put the link. The default Twenty Twelve layout for single.php has a bit of code that looks like this:

    <?php get_template_part( 'content', get_post_format() ); ?>

    That’s where the body of the post is pulled in.

    Immediately below that is the navigation (next/previous). Just below the content is probably a good place to put your links – but that’s really up to you, as it’s your installation. Just make sure you put it inside of the while/endwhile loop. If you don’t, it will be more difficult processing the post information.

    Next, you need to structure your link correctly.

    The general structure of an HTML link looks like this:

    <a href="http://wordpress.org/">WordPress.org</a>

    The part inside the quotes (http://wordpress.org/) is the URL – where the browser will go when you click the link, and is for the machines. The part inside the braces (WordPress.org) is just text for us humans, and can be essentially anything you like, but you probably want it to relate in some way to the link so that people understand the purpose of the link.

    That’s the easy part (really).

    Next, you need to know how to construct a link to the social services in question.

    For Facebook, you need to use this format (which I think still works – though they generally want people to use the like buttons now):

    http://www.facebook.com/sharer/sharer.php?u=URL

    For Twitter, you need to use this format:

    http://twitter.com/intent/tweet?url=URL&text=TEXT

    You need to note that the sharing URL is separated from the parameter by a question mark (?), then you give it a parameter, an equal sign, the value (parameter=value), and if there is a second value, you separate those with an ampersand (&) and another parameter and value (parameter=value). This format is the same for any site, but is especially important here.

    Now, this is a lot of information to process, but I hope you’re still there. Feel free to take a break if you need to. 🙂

    So how do you get this data into the links?

    That is actually fairly easy – and the reason you want to do it inside of the while statement. Because you are inside of that loop, it means that you are processing a post at the time, and you can pull information from that post to create your links.

    Otherwise, you’d have to do more work to get it (or send information manually). Now you could just create links that say “Share to Facebook” or “Share to Twitter” or something – but it would require the visitor to provide information manually, and that wouldn’t be much fun for them. Instead, it is better to populate values for them.

    So you would make use of template tags such as the_permalink to get the URL, which you can then send to your link:

    http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>

    When that displays, you would get the current page. Since you’re in the current post, it would be for that post, which would allow the visitor to share the current post on Facebook, using the current URL – but they would have to copy and paste the code, since it’s not actually a link at this point, it’s just text rather than a friendly, clickable link.

    For that, you’re looking at something more like this:

    <a href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Share to Facebook</a>

    Unfortunately, we’re still not quite there because URLs have characters in them that we don’t want in parameters. So in order to make it work, we need to encode the data with an extra function – creatively called urlencode. Luckily, it’s just a small change to the last bit:

    <a href="http://www.facebook.com/sharer/sharer.php?u=<?php urlencode(the_permalink()); ?>">Share to Facebook</a>

    What that does is encode any characters that can’t normally be processed, and we’re done. With Facebook anyway.

    Now, to Twitter, you could do the same with this:

    <a href="http://twitter.com/intent/tweet?url=<?php urlencode(the_permalink()); ?>">Share to Twitter</a>

    However, it’s only going to post the URL to Twitter. To add the title, you would need to use the_title. You could do something like this:

    <a href="http://twitter.com/intent/tweet?url=<?php urlencode(the_permalink()); ?>&text=<?php urlencode(the_title()); ?>">Share to Twitter</a>

    See how the two parameters (url and text) are separated by an ampersand (&)? And how the values for each are separated by equal signs (=)? And most importantly, how each field (the_permalink and the_title) have been urlencoded? That makes sure that any stray characters are taken care of for us.

    Of course, keep in mind the character limits of Twitter, and so you may not want to send both the url and title to Twitter – just the URL may be fine. But that is entirely up to you, and now you know how to do it.

    Also, you may want to put this all into a div or something so that you could style it with CSS – but that is probably a bit beyond this, and it’s pretty long already. Hope it helps. 🙂

    What exactly are you wanting to accomplish?

    Do you have cat_ID 8 and you want to find the category name that corresponds to it?

    – If so, then get_cat_name may do the trick for you. It returns the name of a category if you feed it a given cat_ID.

    Do you have some string and you want to find the cat_ID that corresponds to that?

    – If so, then using get_the_category, as you do already, but with cat_name, instead of cat_ID, may be the way to go.

    Do you want to do something else?

    – Then that might require a little more information.

    Hi Victoria – It’s certainly up to you if you want to write themes from scratch or not, but if there’s something out there that does close to what you want, you may want to start with that first, as it can often make life easier. Then again, maybe I’m just lazy. 🙂

    As to The Loop, you say you’ve been reading – have you been reading up on the function page? You don’t really have to do so, just trying to get an idea of where you are and what you are comfortable with doing.

    The simplest way to think about it is to just think of The Loop as looping (see what I did there?) through all of your posts. each iteration of The Loop is just one loop through that post. When you are inside The Loop, you are working with one post, and from the while (start) to the endwhile (end), you process that post, and only that one post, so you’re pulling out information on that one post. Everything in between is shown for the post that is current at that time.

    Make sense?

    So what you then need to decide is what you’re going to display about that post. Say you want to display a picture of a particular fence style – you may want to use:

    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      the_post_thumbnail();
    }
    ?>

    To show the featured image/post thumbnail for that post. (You’re first checking to see if there is one, and if so, displaying it.) Of course, you can do other things like adding a title, displaying a link, etc – but this will hopefully give you an idea of what you can do.

    Once you pull out the data, you will of course need to format it, but that’s another issue entirely. Just make sure you are inside of that while statement (The Loop) and you’re all good.

    If you just have the raw WordPress files (that is, the .php files), then unfortunately you may not have anything, as WP stores all of its data in a database.

    If it was exported somehow – either directly from the database or from WP – then there may be something to restore.

    Sounds like you are making good progress. Tags should be fairly similar – you’re just working with a differently named field here. The importer does not do anything with them (I don’t think), so you should be just about there!

    That’s a bit more complex than where we started. 🙂

    What will happen – by default, mind you – is that tags will be imported as tags. I am fairly certain, but have not looked at it in that much detail, is that keywords will also be imported as tags. But put those two aside for the moment.

    The score is the only one addressed by the portion above. You would need to add a separate line to address that section. Something like this:

    } else if ( 'SCORE:' == $line ) {

    That would allow you to save the score into another field – call it $score for the sake of discussion – and then you could save that field into a meta field after saving the post. Something like:

    add_post_meta($post->ID, 'SCORE', $score);

    Where it gets (more) complicated is that you also want to redefine at least the tags function, to not save the tags as tags, but as a custom field, and perhaps do the same as keywords, which typically are saved as tags.

    That means those functions would need to be redefined – generally the same principle, but you would need to make sure the original functions were commented out or otherwise not being run (you could also remove them).

    Possible nevermind: In a quick search of the code, there is actually no reference to tags other than in reference to the comments – and I did not see any in your sample export either. So you may need to add this to your export and you would not have to worry about it on the import. Keywords may be the only issue here, the backwards of what I mentioned earlier.

    Near the top of the process_posts subroutine in the importer, there is a line that looks like this:

    $result = $this->save_post($post, $comments, $pings);

    That happens at the end of each post’s data, and it calls a routine (creatively called… “save_post”), and it is what actually inserts the post into the WP database. At that point, your post will have an ID.

    After that routine, you can use the ID, but the best thing to do is to first save each of your fields into a variable as you are processing them – perhaps an array, depending on the number (1-2 fields might be simpler as individual ones, otherwise an array with all the fields might be easier, that is up to you). If you do not save your fields, you will not have the ID in order to save them as custom fields, and you would have to save them elsewhere.

    Then once the post has been saved – and assuming that the post does not return because of an error – you have an ID, which means you can add code to handle the saving of your fields. This could be immediately after the code above, or it could be within the save_post routine itself, to keep things somewhat organized if you prefer that avenue.

    It would be nice if there was a way to add a filter to handle this, rather than hacking at the code itself, but it does not appear that you can do so – you need to process the text in the file and then you need to adjust/interrupt/piggyback on the save_post routine as well.

Viewing 15 replies - 46 through 60 (of 62 total)