Forum Replies Created

Viewing 15 replies - 151 through 165 (of 496 total)
  • wpismypuppet

    (@wordpressismypuppet)

    How did you place the search box in the sidebar? Did you hard code it yourself? Did you use the search widget?

    If you typed that search box into the sidebar yourself, you can use:

    <?php get_search_form(); ?>

    This will use WordPress default code. If your theme does not have a searchform.php file, WordPress uses a default search form. If you wish to customize the look of the search box, then you’ll need to create a searchform.php file. From there, you can add what you need. Here is one I use:

    <?php
    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
     <input type="text" value="" name="s" id="s" />
     <input type="submit" name="submit" value="Search" />
    </form>
    ?>

    Still use the get_search_form() function above and it will now read your searchform.php file instead of a default form.

    wpismypuppet

    (@wordpressismypuppet)

    I get the Feedburner subscription is all browsers. Looking at your source code, your search input box has no form surrounding it. So when you type in the text box and hit enter, it triggers the first form is finds, which is your email signup. I suggest wrapping your search input box in the appropriate “form” tag and even add a submit button, even if you hide it or change the way it looks.

    wpismypuppet

    (@wordpressismypuppet)

    You are welcome… it could have also been the include statement causing a PHP error, which then caused the rest of the code to fail as well. Glad I could assist!

    wpismypuppet

    (@wordpressismypuppet)

    No, you can… you just need to include the path to the child page. Let’s say “church-resources” is a child page of “about-us”… then you would write:

    <?php
    	$page = get_page_by_path('about-us/church-resources');
    	echo apply_filters('the_content', $page->post_content);
    ?>
    wpismypuppet

    (@wordpressismypuppet)

    Ok… so apparently my code will also close the “Available Widgets” and “Inactive Widgets” meta boxes, which I didn’t notice right off the bat. If this is undesirable, and you only want the right side sidebar widgets to close, modify the code like so:

    if(jQuery('#widgets-right .widgets-holder-wrap').length > 0) {
    	jQuery('#widgets-right .widgets-holder-wrap').each(function() {
    		jQuery(this).addClass('closed');
    	});
    }
    wpismypuppet

    (@wordpressismypuppet)

    That code you are using should work completely fine anywhere on your website. What might not be working is your include statement. Are you getting any error messages when doing this? Also, if a page you are using is already a part of WordPress… ie inside your theme’s folder… you don’t need to include wp-load.php. this is only if you are physically outside of the WordPress directory.

    wpismypuppet

    (@wordpressismypuppet)

    I think I can assist with this… seems easy enough. First, you need to have a JavaScript file that will launch with the admin interface only. So we need to enqueue that file. In your functions.php file, add the following:

    <?php
    	if( is_admin() ) {
    		// Register our admin script files
    		wp_register_script( 'wp_admin_script', get_template_directory_uri() . '/scripts/wp-admin.js', array( 'jquery' ), '1.0', true );
    		// Include custom script files to wp-admin area
    		function custom_admin_scripts() {
    			wp_enqueue_script( 'jquery' );
    			wp_enqueue_script( 'wp_admin_script' );
    		}
    		add_action( 'admin_enqueue_scripts', 'custom_admin_scripts' );
    	}
    ?>

    Based on this code, you should create a file called “wp-admin.js” in a folder called “scripts” in your theme’s folder. If you wish it to be somewhere else, change the code appropriately. Also, I know jQuery is usually already launched with WordPress, but it doesn’t hurt to enqueue it just in case! The function will ignore it if it’s already running, not duplicate it.

    The next piece you’ll want to do is open that wp-admin.js file and add the following to it:

    jQuery(function(jQuery) {
    	if(jQuery('.widgets-holder-wrap').length > 0) {
    		jQuery('.widgets-holder-wrap').each(function() {
    			jQuery(this).addClass('closed');
    		});
    	}
    });

    What that code does is first checks to see if there are any elements on the page that have the “.widgets-holder-wrap” class. If so, loop through each of them and add the “closed” class to them. This will close ALL sidebars by default, but still allow the functionality of click to open/close them.

    If you only want to close the first one by default, let me know. It’s a little more involved, but shouldn’t be too hard.

    wpismypuppet

    (@wordpressismypuppet)

    You are looking to either use a custom field:

    http://codex.wordpress.org/Custom_Fields

    Or you are looking for creating your own shortcodes:

    http://wp.tutsplus.com/tutorials/theme-development/wordpress-shortcodes-the-right-way/

    Not sure which would be easier/best in your case, but since you mentioned shortcode tags in your post, I’m guessing that’s the way you want to start.

    wpismypuppet

    (@wordpressismypuppet)

    Can you give a more details on what you are trying to accomplish? Where are you using that code? Do you have one static page that is pulling content from your WordPress site? Are you using multiple pages? Can you send a link to your existing site where the problem resides? Can you maybe show some code?

    I believe I can help you with this, but right now it’s too vague for me to know where to begin.

    wpismypuppet

    (@wordpressismypuppet)

    You are most welcome. Good luck with the client! Also, you should mark this thread as resolved so others know. Have a nice night.

    wpismypuppet

    (@wordpressismypuppet)

    Ok… so I am guessing you want _recipeingred to be an actual unordered list… so something like:

    • Item one
    • Item two
    • Item three

    If this is the case, we first want to get that string saved into a variable instead of just echoing it out:

    $ingredients = get_post_meta( $postid, "_recipeingred", true );

    Then we’ll want to break the string apart using the line breaks as a divider:

    $ingredients = explode( "\n", $ingredients );

    Now $ingredients is an array! We can go back to your previous foreach loop and create an unordered list:

    echo '<ul>';
    foreach( $ingredients as $ingredient ) {
    	echo '<li>' . $ingredient . '</li>';
    }
    echo '</ul>';

    So the whole thing should look something like this:

    <?php
    	if ( get_post_meta($postid, '_recipeingred', true) ) :
    		// Get the variable from the database as a string
    		$ingredients = get_post_meta( $postid, "_recipeingred", true );
    		// Break the string up by using the line breaks (carriage returns)
    		$ingredients = explode( "\n", $ingredients );
    		// Echo out the title
    		echo '<p>The Recipe Ingredients:</p>';
    		// Start the unordered list tag
    		echo '<ul>';
    		// Loop through each ingredient since it's now an array thanks to the explode() function
    		foreach( $ingredients as $ingredient ) {
    			// Add the list item open and close tag around each array element
    			echo '<li>' . $ingredient . '</li>';
    		}
    		// Once the loop finishes, close out the unordered list tag
    		echo '</ul>';
    	endif;
    ?>

    This isn’t tested, but it should work. If there are any bugs, let me know and I’ll be able to correct them.

    wpismypuppet

    (@wordpressismypuppet)

    I apologize… it’s late and I’m a little tired :). My second code is what you want, but you’ll want to echo out the apply_filters…

    <?php
        if ( get_post_meta($postid, '_recipeingred', true) ) :
            echo '<p>The Recipe Ingredients:</p>';
            echo apply_filters( 'the_content', get_post_meta( $postid, "_recipeingred", true ) );
        endif;
    ?>

    However, all this will do is echo out the _recipeingred as it was typed into the field. If you truly want to expand that into a physical ordered/unordered list, let me know and I can help you with some PHP str_ireplace functionality.

    wpismypuppet

    (@wordpressismypuppet)

    Oh wait… I misread your data… it looks as though the data is being stored as one long string, but it looks as though it has line breaks stored with it. In this case:

    <?php
        if ( get_post_meta($postid, '_recipeingred', true) ) :
            echo '<p>The Recipe Ingredients:</p>';
            apply_filters( 'the_content', get_post_meta( $postid, "_recipeingred", true ) );
        endif;
    ?>
    wpismypuppet

    (@wordpressismypuppet)

    I can offer assistance! Normally I would point you to a tutorial, but it looks like you already have a good grasp of what you are doing.

    Your foreach loop is the way to go! However you don’t need to echo out $key, as that is only the index of the array element. What you want is to simply echo out the unordered list html elements with your $value:

    <?php
        if ( get_post_meta($postid, '_recipeingred', true) ) :
            $unorderedList = get_post_custom_values('_recipeingred',$postid);
            echo '<p>The Recipe Ingredients:</p>' . '<ul>';
            foreach ( $unorderedList as $value ) {
                echo '<li>$value</li>';
            }
            echo '</ul>';
        endif;
    ?>
    wpismypuppet

    (@wordpressismypuppet)

    Why not try:

    if( get_option( 'jr_sharethis_id' ) && is_single() )
        add_action( 'wp_head', 'jr_sharethis_head' );

    Since you only want it on single posts… this code will also work for any single custom post page as well.

Viewing 15 replies - 151 through 165 (of 496 total)