Forum Replies Created

Viewing 15 replies - 46 through 60 (of 2,107 total)
  • If your theme supports custom menus like the twenty eleven theme then you can just add the categories to the menu tree, like this test website, all the menu items are just categories selected in the custom menu screen.

    Screenshot: Admin > Appearance > Menus

    The home page can then be a static page or a latest posts page.

    HTH

    David

    Hi John,
    I do have examples and use them in my child themes, the starkers theme is based on the twenty ten theme I think?

    I wrote a post back in February 2011 with a tabbed options page, this should work fine with the starkers theme.

    I will be writing an updated version using the WordPress admin layout this weekend that will also work with most themes, so check my website at some point over the weekend.

    HTH

    David

    Great, I have updated the example above, interesting topic, is this to prove that the user has visited the website and generated a ‘Promo Code’, how is it then used, it could be used as a download check I expect?

    Please mark this topic as resolved!

    David

    Hi,
    This post might be a better way to do it, it is an old post but looks like it will give you a start.

    It adds a field to the users profile and saves it as metadata.

    Set the Meta data:

    if( $_POST["promokey"]=='membersonly' ) {
       /* Create the Promo Code Here */
       function make_seed(){
         list($usec, $sec) = explode(' ', microtime());
         return (float) $sec + ((float) $usec * 225);
       }
       mt_srand(make_seed());
       $promo_code = mt_rand();
    
       /* Save the Promo Code here */
       update_user_meta( $user_id, 'promo_code', $promo_code );
    }

    Get the meta data

    $promo_code = the_author_meta( 'promo_code', $user_id );

    Edited: After Reply Below

    HTH

    David

    Hi,
    The client would not edit the files and the values should not be hard coded.

    Options
    Text Widget:
    Use a text widget in the footer widget area, add the details in the content area of the text widget, you can use html tags in a text widget, then show the client how they can change the number.

    Theme Setup Page:
    Create a theme setup page with the text boxes you require, the client can then update them as and when they need to, this would mean you will code the header and footer to get the values from the setup array.

    Choose a Theme:
    Different themes will have options, some may have shortcodes or functions to do what you want “out the box”.

    What theme are you using?

    HTH

    David

    The main thing I would like to change is the “Get It” button text. Obviously this applies to the mixtape post, however on the news posts I would like to alter this.

    The text GET IT! for this button is set in the theme options, it will change it globally.

    We need to change it just for the news page?
    the category-news.php you created calls the template part:

    get_template_part('post', 'category');

    Change this to:

    get_template_part('post', 'news');

    The file post-news.php does not exist so it will use post.php, you will need to create it, open the file post.php and save it as post-news.php

    Find these lines:

    <div class="readmore">
                <a href="<?php the_permalink(); ?>#more-<?php the_ID(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'themater' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php $theme->option('read_more'); ?></a>

    Replace this part:

    <?php $theme->option('read_more'); ?>

    With:

    <?php echo __( 'Read More!', 'themater' ); ?>

    Now the news category page will say Read More!

    HTH

    David

    Also have a look at custom post types, this is an ideal candidate for custom post types, there are a number of plugins for custom post types, this plugin looks like it will do all you want “out the box”, it is recently updated.

    That way you are not adding tables to the database and all the WordPress API functions are there to be used.

    Regards

    David

    Are you talking about the single post?

    Twenty Eleven: the single post is rendered in single.php and content-single.php, as you have not said what theme you are using it is hard to help.

    A single post could belong to a number of categories, news,sport,tennis, so it might not work the way you want it to, unless you take the first category:

    single.php (outside the loop)

    <?php
    global $post;
    $category = get_the_category( $post->ID );
    $class = isset($category[0]) ? $category[0]->cat_name : '';
    ?>

    Then use this:

    body_class( $class )

    content-single.php (inside the loop)

    <?php
    $category = get_the_category();
    $class = isset($category[0]) ? $category[0]->cat_name : '';
    ?>

    Then use this:

    post_class( $class )

    Then in syle.css add the category styles

    .news .entry-title a {
        color: #444444;
    }
    .weather .entry-title a {
        color: #CCCCCC;
    }

    HTH

    David

    Widget logic if you want to switch off single sidebar widgets.

    Another Way:
    Create your new sidebars in functions.php as per your code above.

    Your sidebar code should be in a file called sidebar.php, if not then copy it to a file sidebar.php

    Open sidebar.php and save as sidebar-{slug}.php so this could be sidebar-home.php, sidebar-one.php, sidebar-single.php, sidebar-archive.php, sidebar-search.php, sidebar-members.php, sidebar-foo.php, sidebar-bar.php, sidebar-foobar.php, anything you want after the hyphon ‘-‘ all lowecase single word.

    Inside the copied file just change the dynamic_sidebar({$slug-name}) for your new sidebar.

    Then in the templates files call the different sidebars with or without a conditional statement.

    Example page.php

    <?php if (is_page('1,2')) : ?>
       <?php get_sidebar('one'); ?>
    <?php else : ?>
       <?php get_sidebar(); ?>
    <?php endif; ?>

    Example single.php

    <?php get_sidebar('single'); ?>

    Example search.php

    <?php get_sidebar('search'); ?>

    Example archive.php

    <?php get_sidebar('archive'); ?>

    Example index.php

    <?php if ( is_user_logged_in() ) : ?>
       <?php get_sidebar('members'); ?>
    <?php else : ?>
       <?php get_sidebar(); ?>
    <?php endif; ?>

    HTH

    David

    Hi,
    Not all themes support child themes, is this just a theme or a framework?
    Is the new theme a free download theme?
    Do you have a test site you can link to?

    Is your child themes style.css correct?
    Template: {slug} is the themes folder name, this must be exactly the way it looks in a file manager, this is case sensitive, and must not have spaces in the folder name:

    This will not work:
    /wp-content/themes/My Child Theme/
    Template: My Child Theme

    This will not work:
    /wp-content/themes/My-Child-Theme/
    Template: my-child-theme

    This will work:
    /wp-content/themes/My-Child-Theme/
    Template: My-Child-Theme

    This will work:
    /wp-content/themes/My-child-theme/
    Template: My-child-theme

    This is best all lower case:
    /wp-content/themes/my-child-theme/
    Template: my-child-theme

    HTH

    David

    Hi,
    Creating the post type:
    I have a custom post type called information this is created with code in functions.php

    The template page:
    I open single.php and save this as information.php

    The content: (loop)
    If there is a loop-single.php or content-single.php file, I open and save this as loop-information.php or content-information.php

    Within these files I can add a body class, post class, or add any page specific changes like the post thumbnail etc:

    The code snippet above is also in the functions.php file, this tells WordPress to use information.php for the ['post type'] == 'information'

    Conclusion:

    The reason is because I will be styling this post type a certain way

    Looking again at the template heirarchy and your question, if it is a custom post type, just forget the code, open single.php and save it as single-{$posttype}.php (like: single-information.php)

    Do as above with the loop file if you are required to change the content layout.

    Then just add your styles classes to the new files.

    HTH

    David

    Thread Starter Digital Raindrops

    (@adeptris)

    Hi esmi,
    Same as the twenty eleven parent GPL 2.0!

    I did miss the line it in the child themes style.css, I assumed it would inherit the parents license from twenty eleven.

    I have added it and the license to the child theme’s download.

    Cheers

    David.

    Hi,
    When you say a certain post type do you mean a custom post type, is this a page, a post or a custom post type?

    When we know this we will be able to help more.

    Also have a look at the template heirarchy, as single-{$posttype}.php would work, lets use film as a post type then, single-film.php could be used.

    For a specific page page-{$slug}.php so page-news.php, or page-{$id}.php, page-234.php

    Then you can use the post_class(‘my-class’) in the new file just for that single instance, I wrote about post classes recently so this post may help.

    I have a custom post type in a child theme called information, I just copy single.php as information.php then add in functions.php

    /* Information Posts Template selection - a single.php just for our information posts */
     function dr_info_template_redirect() {
    	global $wp;
    	if ($wp->query_vars['post_type'] == 'information') {
    		if( file_exists( get_stylesheet_directory() . '/information.php') ) {
    			include( get_stylesheet_directory() . '/information.php');
    			die();
    		}
    	}
     }
    add_action("template_redirect", 'dr_info_template_redirect');

    HTH

    David

    From what I read, the child function may load before the parent theme, but if you have the SAME functions, you’re declaring it twice and it can crash the site

    Hi brisus,
    WordPress loads in this order:
    Child Themes functions.php
    Parents Themes functions.php

    We add a function to the child theme with an ‘after_setup_theme’ hook to over-ride the parent functions.

    If a parent function is pluggable we can load the function in the child theme, once loaded the parent will not try to load the function and will not error.

    If a function is not pluggable we would have to create a new function and find where the function is called and rename the calls in our child theme.

    We can also remove filters and actions, then replace them with our own.

    I thought this would make an interesting topic for others, so I created a YouTube overview video this morning: here with examples for the twenty eleven theme, view at a larger size.

    HTH

    David

    Use a text compare like examdiff to find your changes, if you have a copy the original theme files, and create the child theme from the changes.

    Sample child themes functions.php, /* comments to help what goes where */

    <?php
    /* This Section Will Run first before the parents functions.php */
    
    add_action( 'after_setup_theme', 'post_theme_setup' );
    if ( !function_exists( 'post_theme_setup' ) ):
    function post_theme_setup() {
    	/* This Section Will Run Last after the parents funtions.php */
    
    }
    endif;

    HTH

    David

Viewing 15 replies - 46 through 60 (of 2,107 total)