Forum Replies Created

Viewing 15 replies - 46 through 60 (of 855 total)
  • Forum: Fixing WordPress
    In reply to: Custom taxonomy

    Well, not to be to mean, but as someone once said to me on this forum – the best way to learn is to try it yourself. Plus, you are the only one that knows the exact requirements of your project.

    I’ve given you the code for adding a metabox to your posts screen, so you are 75% of the way there.

    The Codex for WP AJAX should get you started – it has lots of links to useful sites/examples – AJAX ? WordPress Codex.

    Can you please post your code.

    Try this –

    $post_parent = get_post($post_id = 80);

    If that fails, place this directly after that line –

    echo '<pre>'; print_r($post_parent); echo '</pre>';

    I wonder if the error is infact being caused by echo $post_parent->post_title; – it could be that the page is not being found, so you are trying to output from an object that does not exist.

    And which of these lines is line 18 in your code? Also, what version of PHP are you using?

    I don’t understand this –

    The key of this peace of code is that the slug of the artist page is the same meta value I give an album. This way every artist page should get their own albums listed.

    Do you mean that, taking The Killers as an example, you have 4x Pages –

    • Hot Fuss
    • Sam’s Town
    • Sawdust
    • Day and Age

    – that each of these pages will have a custom field ‘artist’, which is set to ‘The Killers’?

    I maybe totally misunderstanding you, but if that is the case, you structure may be overyly complicated. Why not just have a Post with some custom Taxonomies – ‘Artist’ (non-hierarchical), ‘Year’ (non-hierarchical), ‘Genre’ (hierarchical).

    That way, you could simply display all posts from The Killers by going to https://www.yousite.com/artist/the-killers/. You could also use the custom menus (found under ‘Appearence’ in the admin) to build a menu for the site.

    What PHP error?

    I’m clearly not as experienced with rewrite rules as you, but I seem to remember that the best way to add rewrite rules is add_rewrite_rule($rule, $rewrite, $position);Function Reference

    The $positoin variable allows you to specify ‘top’, so that these rules are met before others, and will override any potential conflicts.

    Also, a little rusty on the rules, but wouldn’t it be 'index.php?p=$matches[1]'?

    Not sure how your site is set up, so can’t be sure, but do you have a ‘search.php’ file? If so, it is possible that you are simply not adding the menu (where as ‘index.php’, ‘single.php’, etc.) may have the code to add it.

    Who are you hosting with?

    What typically happens is that the permissions for the files and directories where your WP is located are incorrect. If it’s a local install, try changing them to 777 and then upgrade. If it works, you know that was the issue (but don’t forget to change the permissions back).

    I do remember seeing somthing in the past, about an older version of WP, where there was a problem with only Admins being able to use certain tags. If you were not an admin they were stripped when you published the post.

    Are you an admin on your site, or something other (editor, author, etc.)?

    Forum: Fixing WordPress
    In reply to: Custom taxonomy

    Ok, so just so that I am clear –

    • You would like to add a custom taxonomy to a post type.
    • You would like to be able to add multiple terms from the custom
      taxonomy to the post type.
    • You would like for the terms to be displayed in a dropdown menu.

    Assuming all this is true, I believe you just need to add true to the wp_add_object_terms() line, right near the bottom of the save function. This should make it update, rahter than replace the term entries for your custom taxonomy that are associated with that post.

    wp_set_object_terms($post_id, $sector, TAXONOMY_SECTOR, true);

    This of course will not add the ‘Add’ button. There are two ways you can do this –

    1. Add a button that, when clicked, acts simply as the ‘Publish’ button.
    2. Add an button that calls an AJAX routine when it is clicked, updating the database in the background.

    Ah, with you. I use a plugin called Post2Post by Scribu.

    You create a link in your ‘functions.php’ file, and then you literally link the posts to each other in the post edit screen. There are then all sorts of new arguments that you can add to your query to code to grab the posts you want.

    Scribu has a page for this plugin that offers tips for beginners and shows code for certain scenarios. He will also come on here and offer support should you hit problems.

    I realiase I msiread your post – my code above will only output the Post Parent ID. This code below (where 99 is the ID of the parent) should do the trick.

    This will show the tile of the Post Parent for ALL pages that are a direct-child of Page ID 99.

    <?php
    if($post->post_parent === 99) :
    
        $post_parent = get_post(99);
        echo $post_parent->post_title;
    
    endif;
    ?>

    To make it so that only one single child shows this, add a condition to check for the ID of the Page that is being shown (where 101 is that ID) –

    if($post->post_parent === 99 && $post->ID === 101) :

    Forum: Fixing WordPress
    In reply to: Nav menu order.

    It’s probably just a typo that I made. What is the error that you are getting?

    Thread Starter David Gard

    (@duck_boy)

    Ok, so for this you should check if a Password is required before showing any of the post content, that way when the_content() or get_the_content() are called, the password has already been entered, so the form will not show up again.

    This also prevents other content that is not called via those functions (like my list of attachments) from being displayed before the password has been entered.

    Note that this code is for use in The Loop.

    <?php /** Check to see if a password is required */ ?>
    <?php if(post_password_required($post)) : ?>
    
    	<?php echo get_the_password_form(); ?>
    
    <?php else : ?>
    
    	<?php if(get_the_content() !== '') : ?>
    
    		<div id="post-content">
    			<?php the_content('<p class="serif">Read the rest of this entry ?</p>'); ?>
    		</div>
    
    		<div class="line-seperator-dotted">?</div>
    
    	<?php endif; ?>
    
    	<?php $children = get_children(array('post_parent' => $post->ID)); ?>
    	<?php display_attachments($children); ?>
    
    <?php endif; ?>
Viewing 15 replies - 46 through 60 (of 855 total)