Showing posts with label Wordpress tips. Show all posts
Showing posts with label Wordpress tips. Show all posts

WP-Snippets | Hacks, Snippets and Articles

WP-Snippets | Hacks, Snippets and Articles

GOOD WordPress.com Theme: Twenty Eleven CSS Style Sheet Modification. Change Site Title,Description,Post Title,Comments,Menus,Sidebar and More. | All About Basic

WordPress.com Theme: Twenty Eleven CSS Style Sheet Modification. Change Site Title,Description,Post Title,Comments,Menus,Sidebar and More. | All About Basic


LOTS OF CSS

http://allaboutbasic.com/2011/06/15/wordpress-com-theme-twenty-eleven-css-style-sheet-modification-change-site-titledescriptionpost-titlecommentsmenussidebar-and-more/

How to remove / disable "Leave a Reply" from WordPress Twenty Eleven theme? | WordPress Rockers

How to remove / disable "Leave a Reply" from WordPress Twenty Eleven theme? | WordPress Rockers

How to remove / disable “Leave a Reply” from WordPress Twenty Eleven theme?

Removing Comment Box for Twenty-Eleven with CSS Custom Design � WordPress.com Forums

Removing Comment Box for Twenty-Eleven with CSS Custom Design � WordPress.com Forums: #comments {
display: none;
}

CODE FOR CHANGING PAGE WIDTH WordPress › Support � Change width twenty eleven theme

WordPress › Support � Change width twenty eleven theme

*/
@import url("../twentyeleven/style.css");
#page { max-width: 1200px; }

Overriding WordPress Functions | venutip.com

Overriding WordPress Functions | venutip.com

he Right Way to Override Theme Functions

I started building my first WordPress site last week and almost immediately starting customizing the theme. Rather than editing the default theme directly, however, I created a child theme, basing it off one of the many theme frameworks available for WordPress. Creating the child theme was painless, and there is plenty of information on how to do so.
Pretty soon though, I got to the point where tweaking CSS rules wasn’t going to cut it: I needed to go deeper. I needed to change some of the functions in the parent theme. But while there was plenty of information on creating child themes, information on overriding theme functions was nowhere to be found. The closest I came was this helpful post.
This is an odd disconnect. How could there be so much information on one part of a best practice (creating a child theme), but basically none on how to make that best practice really work?
I can’t answer that question. But I do have my own version of how to override theme functions in WordPress – The Right Way.

The Child is the Father of the Man

(Bonus points if you get the reference.)
Here’s the basic outline for what I think is the Right Way To Do It:
  1. Copy (in full) the function you want to override from the parent theme.
  2. Paste it into functions.php in the root of your child theme’s folder. If functions.phpdoesn’t exist, create it.
  3. Rename the function from parent_theme_function to child_theme_function.
  4. Deactivate the parent function.
  5. Activate the child function.
The first three steps are self-explanatory, so I’ll just cover the last two steps.

Deactivate the Parent Function

There are actually two steps here. First, create a one-line function that removes the parent function from its “phase”. Then, add that one-line function to WordPress’ bootstrap phase (‘init’), so that the parent function actually gets removed.
Confused? Don’t worry. Here’s an example of how you would remove the thematic_blogtitle()function from the Thematic theme. Code comin’!
// Remove the default Thematic blogtitle function
function remove_thematic_actions() {
    remove_action('thematic_header','thematic_blogtitle',3);
}
// Call 'remove_thematic_actions' (above) during WP initialization
add_action('init','remove_thematic_actions');
In this case, we are removing the parent theme function (thematic_blogtitle) from thethematic_header phase.
How do you know what the proper phase is? Look for a line like this in the parent function’s theme files:
add_action('phase','function', 'priority');
You can usually find this right after the function’s declaration. The line that addsthematic_blogtitle looks like this:
add_action('thematic_header','thematic_blogtitle',3);  
Note that you have to use the same priority that was used to add the function in the parent theme (in this case, 3) when you remove it. If no priority was used in the original add_action, you can skip it.

Activate Your Child Function

To replace thematic_blogtitle, we just need to tell WordPress to call our child theme function in the place where it used to call the parent theme function. So, if our new function were calledfancy_theme_blogtitle, we would add the following to functions.php:
add_action('thematic_header','fancy_theme_blogtitle', 3);
Save functions.php and voila! The code from fancy_theme_blogtitle is run instead of the code from thematic_blogtitle, and we didn’t have to hack the parent theme. This is crucial, because if there is ever an update to Thematic, we can get all the upgradey goodness without having to worry about how it will affect our child theme. Excellent!

All Together Now

Putting all the code together:
// Removes thematic_blogtitle from the thematic_header phase
function remove_thematic_actions() {
    remove_action('thematic_header','thematic_blogtitle',3);
}
// Call 'remove_thematic_actions' during WP initialization
add_action('init','remove_thematic_actions');

// Add our custom function to the 'thematic_header' phase
add_action('thematic_header','fancy_theme_blogtitle', 3);


Creating your first WordPress child theme | Webdesigner Depot

Creating your first WordPress child theme | Webdesigner Depot

http://www.webdesignerdepot.com/2011/12/creating-your-first-wordpress-child-theme/

WordPress › Support � Customising Twenty Eleven theme REMOVE SEARCH FORM TAGS

WordPress › Support � Customising Twenty Eleven theme:

#branding #searchform { display:none; }

also code for removing tags at the bottom of posts

Twenty Eleven Comment Bubble � WordPress.com Forums

Twenty Eleven Comment Bubble � WordPress.com Forums

.entry-header .comments-link a { display: none; }

Custom Header: Twenty-Eleven Child Theme | randyzwitch.com

Custom Header: Twenty-Eleven Child Theme | randyzwitch.com

http://randyzwitch.com/custom-header-twenty-eleven-child-theme

Changing header image and size

Of all of the great things about the WordPress Twenty-Eleven theme, the one thing I can’t understand is why WordPress decided to make the header image so damn big!  There is the option to change the image you display to any number of provided images, or upload your own as part of the Appearance > Header menu.  But you can’t change the size…if your upload is too short, the theme will stretch it for you, distorting the image.  If your upload is too large, you’ll have to crop it. Luckily, with a minor modification we can change that.
First, go your newly created header.php file and find the following code:
1234
<?php // Check to see if the header image has been removed
$header_image = get_header_image();
if ( ! empty( $header_image )) :
?>
What we’re going to do is use the commenting tag in HTML to “comment out” the portions of our header code that we no longer want to be active (i.e. the re-sizing feature in the Twenty-Eleven theme).  We can do this by adding the following tag (a left arrow, and exclamation point, and two dashes):
1234567
<!-- Comment out WordPress header checking
<?php // Check to see if the header image has been removed
$header_image = get_header_image();
if ( ! empty( $header_image )) :
?>

You’re not required to put in the “Comment out WordPress header checking” text as I did, but it is good practice to notate why changes have been made to your code.  A little documentation now goes a long way a year from now, when you can’t remember why you changed something! Now that we’ve got the opening tag for commenting, we need to find the end of the code we want to comment out, and put the closing tag.  Once we do this, all of the code between the commenting tags will not get executed by our browser.
1234
<?php endif; // end check for removed header image
?>
End of RZ commenting out -->

The closing tag above is the two dashes, then the right arrow.  Again, you don’t have to write “End of RZ commenting out”, but it’s good for documentation.  Save your header.php file to make the completed changes.

Hey, now I don’t have ANY banner!

If you refreshed your blog at this point, you’ll realize that not only did we get rid of the massive size of the banner, we got rid of the banner overall!  That’s not the goal of this tutorial…so let’s add the banner back, except now we’ll control the sizing.
First thing you need to do is make sure you have the banner you want uploaded to your server, and that it is the size you want.  This blog is 1000 pixels wide at the body (white space), and I decided to make my banner 225 pixels tall, because that’s where the picture looked good.
Once you have your banner location, we need to add the HTML link to our image, using the image tag.  For the “alt” section, you should put a description of what your banner represents, as this will be displayed if the users browser can’t download the image.  In the “src” section, add the location of your banner file.
12
<img src="http://randyzwitch.com/wp-content/themes/twentyeleven-child/images/butlers-wharf.png" alt="randyzwitch.com
header" />

Once you hit save, that’s it!  You now have control over your banner image.  Yes, modifying the code in this manner disables the Appearance > Header functionality in the theme, but that’s a small price to pay to get flexibility.  If you want to change your banner in the future to show a different image, you’ll need to do so in the header.php file.  But since you’ve documented this change in your code, you’ll know where to look and what to change when that time comes…

WordPress › Support � Having pages show in sidebar but not top menu

WordPress › Support � Having pages show in sidebar but not top menu

http://wordpress.org/support/topic/having-pages-show-in-sidebar-but-not-top-menu?replies=3



  1. What I would like is to be able to have the pages widget in my sidebar, displaying ALL my pages... but for the top menu to only show 2 or 3. Is this possible? I see this plugin (http://wordpress.org/extend/plugins/exclude-pages/) but it implies that the tick box would remove the page from ALL menus, which I don't think is what I need.
    Also - is there a way that my sidebar page widget can show only certain subpages, dependant upon which top level page I am on? For example - if I am on the top level page "Food", I'd like the subpages "starters", "mains", "desserts" to also show... But not subpages of "Venues" such as "venue 1", "venue 2", "venue 3" etc. I would only want the "Venues" subpages to show if I am on that toplevel "Venues" page itself. Can anyone tell me if this is possible too?
    I have not yet built the site, as it is only in a quote stage... so i cann't post a link to show anyone - but I will be using Artisteer for the theme, if that helps anyone answer.
    Please be gentle with me, as this little lady is very confident with wordpress and artisteer... bu not with coding as such (only the basics for me).
    Thanks!
    E x
  2. MichaelH
    Member
    Posted 3 years ago #
    The template tag, wp_list_pages(), is typically used by theme designers to display Pagesin a nav bar. With the help of the Template Hierarchy article, determine what Template is displaying your Pages (probably header.php), then look for wp_list_pages and co

WordPress › Support � How to control which pages appear in menu

WordPress › Support � How to control which pages appear in menu

http://wordpress.org/support/topic/how-to-control-which-pages-appear-in-menu?replies=22

Creating a Search Page � WordPress Codex

Creating a Search Page � WordPress Codex
borrowed from http://codex.wordpress.org/Creating_a_Search_Page#Using_the_page.php

Creating a Search Page

Contents

[hide]
A Search Page is a WordPress Page with a custom Page template to give users more information for searching your site.

Things You Need to Know

Different WordPress Themes feature different template files. Some include asearch.php template file. This is not a Search Page, it is merely a template that displays the search results. There is also a template file calledsearchform.php. This is a template file that is often included in the sidebar of many themes and generates the search box form. If there isn't one in your theme, you can easily copy it from the Default theme.
To create your own custom Search Page, you will need to create a Page template to include your search form and the information you want your users to see before they search your site.
Check your WordPress Theme to see if it includes a page.php template file. The Default WordPress Theme does include this template, but many do not. If it does, then follow these instructions. If it does not, we have the information you need to create your own.

Using the page.php

1. Using a text editor, open the page.php and save as searchpage.php. (Note: The filename search.php is reserved as a special template name, so avoid its usage; the suggested searchpage.php just makes it easy to recognize in the list of files.)
2. After saving it, edit the file:
  • Delete The Loop (i.e. basically everything within your content div), leaving the div tags intact.
  • Add a heading such as "Search Posts" or something similar. You can use an existing class from your CSS style sheet, or create a new one.
  • Copy the following into the content div or any other div that contains the content of your Page:
<?php get_search_form(); ?>
  • At the top of your searchpage.php, before anything else, add this to give your Search Page a heading WordPress will recognize in the Administration Panels:
<?php
/*
Template Name: Search Page
*/
?>
  • Save the file
  • Upload the file to your theme directory (if you made changes to your style.css style sheet file, upload that, too).
  • In the Administration Panels go to Write > Write Page.

    WordPress Write Page Panel
  • In the title field enter Search.
  • Do not write anything in the content area.
  • From the Page Template drop-down menu select: Search Page
  • Click the Create New Page button
  • Select the Manage Pages panel.
  • Write down the page_id number of your newly created Page named Search Page.
You are now ready to customize the look of your Search Page.

Creating a Search Page Template

If you do not have a page.php, you can create one based upon your Theme's index.php template file.
  1. In a text editor, open your theme's index.php and save as searchpage.php.
  2. Then follow the editing steps from above.

Preserving Search Page Results and Pagination

Search results and Pagination may stop working when applying customization to the search template. To avoid these issues the first thing any developer needs to do is add the following code to the start of their Search template to ensure that the original WordPress query is preserved. To customize the query append additional arguments to (array) $search_query. Execute the $search_query through a new $wp_query object, more information on the WP_Query object can be found athttps://codex.wordpress.org/Class_Reference/WP_Query
<?php
global $query_string;

$query_args = explode("&", $query_string);
$search_query = array();

foreach($query_args as $key => $string) {
 $query_split = explode("=", $string);
 $search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach

$search = new WP_Query($search_query);
?>
Additional customization arguments can be found on the Codex at https://codex.wordpress.org/Class_Reference/WP_Query

Display Total Results

To access the total number of search results from a search, you should retrieve the total number of posts found using the wp_query object.
<?php
global $wp_query;
$total_results = $wp_query->found_posts;
?>
More information on WP Query can be found on the Codex at https://codex.wordpress.org/Class_Reference/WP_Query

Linking to Your Search Page

You can now make a link to your custom Search Page in several ways.
Using the Page ID 
Whether or not you use permalinks, you can link to your new Search Page by using Page ID number of the Page.
<a href="index.php?page_id=17" title="Search Page">Search Page</a>

OR

<a href="<?php bloginfo('url'); ?>/?page_id=17">Search Page</a>
Using the Page Slug 
The Page slug is set in the Edit Page panel. It is the name of the page if you are using Permalinks. You can manually change this. An example of a Page slug link would be:
<a href="/wordpress/search-page" title="Search Page">Search Page</a>

OR

<a href="<?php bloginfo('url'); ?>/wordpress/search-page" title="Search Page">Search Page</a>
Using wp_list_pages() 
If you are using the wp_list_pages() template tag, the page name would be automatically generated in your Pages list.

Customizing Your Search Page


Manage Pages Panel
Now that you have created your custom Search Page, you can customize the display. From the Manage >Pages panel, on your custom Search Page line, choose Edit. Or open your searchpage.php in a text editor and edit it there.
Above the include function for your searchform.php within the content div, you can add text to help visitors search your site.
<p>
My Site features articles about 
<a title="WordPress Articles" href="index.php?cat=4">WordPress</a>, 
<a title="Web Design Articles" href="index.php?cat=5">web page design</a>, 
<a title="Development Articles" href="index.php?cat=6">website 
development</a>,
and <a title="CSS Articles" href="index.php?cat=7">CSS</a>.
</p>
<p>To search my website, please use the form below.</p>

<?php get_search_form(); ?>
You might want to include a list of keywords or other information, images, or details to customize your custom Search Page.

Extend WordPress Twenty Eleven Theme to Include Sidebars and More Flexible Options - WPMU.org

Extend WordPress Twenty Eleven Theme to Include Sidebars and More Flexible Options - WPMU.org

http://wpmu.org/extend-wordpress-twenty-eleven-theme-to-include-sidebars-and-more-flexible-options/
\

WordPress › Support � How i can remove search box in header. Thaem is AndyBlue 1.5

WordPress › Support � How i can remove search box in header. Thaem is AndyBlue 1.5

  1. Friends i been seeking for a help about this issue.
    There in Appearance => Editor
    I found " Search Form " on the right side under Theme Files Template Files
    I was to simply remove all the text in that file " searchform.php " and update the file
    Now i look at my Blog and search is no longer there in header.
    Thanks to WordPress.org n WordPress.com for giving us such great open source free services.
    Also thanks to all developers who have been working to update wordpress.
  2. isw79
    Member
    Posted 3 years ago #
    You have to chmod with 777 the files that you want to change otherwise you will never change anything using wordpress html editor
  3. isw79
    Member
    Posted 3 years ago #
    If you want to remove the search box, please open header.php and remove the line
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
  4. grvpande
    Member
    Posted 3 years ago #
    In header.php at line no. 26 you'll fine this code
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    now if you want to remove it delete the code or you want to change the position paste this code wherever you want.
  5. jeratbp
    Member
    Posted 3 years ago #
    Here's the code in the Header.php file that I had to remove.
    <div id="search2">
    <form method="get" id="searchform2" action="<?php bloginfo('home'); ?>/">
    <div><input class="searchinput" type="text" onfocus="doClear(this)" value="<?php _e('Search'); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit2" class="search_button" value="Search" />
    </div>
    </form>
    </div>
    Jeremy