Forum Replies Created

Viewing 15 replies - 1 through 15 (of 68 total)
  • Thread Starter get_username

    (@get_username)

    After many searches, guessing at what to search for, this solution works. I’d like if someone could check my logic. Is this the expected way to handle custom background images and custom fields on the Posts Page?

    For the background “Featured Image” on the Blog home page.

    <?php
        if (is_home()) {
            $hero = wp_get_attachment_image_url( get_post_thumbnail_id(get_option('page_for_posts')), 'full' );
        } else {
            $hero = wp_get_attachment_image_url( get_post_thumbnail_id($post->ID), 'full' );
        }
    ?>

    For the custom fields on the Blog home page.

    <?php
        if (is_home()) {
            the_field('header_headline', get_option('page_for_posts'));
        } else {
            the_field('header_headline');
        }
    ?>

    Could I have done this differently? Is there a standard? Thanks!

    Thread Starter get_username

    (@get_username)

    I just came across a post with this interesting code snippet.

    <?php if(is_home()) {
        $img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full');
        $featured_image = $img[0];
    }?>

    It looks like it gets the ID of the page you set under “Reading Settings.” I haven’t tested yet, but looks promising. I assume I would set the condition based on is_page(‘blog’) instead of home?

    Thread Starter get_username

    (@get_username)

    It appears that using a template for blog posts is incorrect as pointed out here. I am setting all of my header background images in header.php, so I’m not sure how template hierarchy plays out here. If I use index.php or home.php they are still pulling from the same header.php file.

    Thread Starter get_username

    (@get_username)

    Thanks for the reply. I hadn’t thought about the other pages that this would happen on such as category.php, tag.php, archive.php, etc. I wonder if I’m approaching this correctly? Without hardcoding the “background-image” is there another way to loop into the featured image? I’m not sure what the more specific query is that you’re referring to. Do I need a custom template for my “blog” page or would that not work either because, like you said, there are other pages like archive.php. Thanks for any additional help you can provide.

    -Burt

    Thread Starter get_username

    (@get_username)

    Hey David,

    I think there is some confusion around the drop-down. I don’t need jQuery for my drop-down menus as they are all CSS driven. I was referring to using jQuery for the mobile navigation.

    I’m pretty solid when it comes to html and css, and I understand drop-downs, but every post I read about responsive navigation has some sort of JS or jQuery involved.

    Thread Starter get_username

    (@get_username)

    I’m beginning to think you’re right, David. The more I read, the more I realize I need to learn more. While I know what a media query does, I think understanding how to position things with them will help.

    Thread Starter get_username

    (@get_username)

    I think another thing that is throwing me off is the drop-down menu. Having just buttons without the drop-down makes more sense. I wonder if I’m over thinking it. Does having a drop-down just require an additional click that is similar to the mobile “menu” button?

    Thread Starter get_username

    (@get_username)

    Thanks again, David. I understand media queries more than I understand the implementation of these menus. I’ve built my own responsive framework from the ground up, so I feel comfortable using media queries. Maybe I’m missing your point, and I apologize for that. I will definitely read more into that article as a refresher.

    I’ve created my basic CSS drop-down nav, but have not created the mobile version yet. What I’m struggling with is the implementation of JQuery to get the menu to work correctly. Especially, the drop-down in mobile view, and reveling the menu on click.

    If I break down what you’re saying, it sounds like I need to get my menus working in standard view – which I have already – then mobile view. And getting these to display correctly using my media queries. Once those are set, worry about the JQuery and how it animates the menu. Correct me if I’m wrong.

    Thread Starter get_username

    (@get_username)

    Something like this, but with drop-down and WordPress support.

    https://responsive-nav.com/

    Thread Starter get_username

    (@get_username)

    Thanks, David. I’m actually pretty familiar with the “ins and outs” of digesting code. I constantly study other people’s code as well. So the problem isn’t in my ability to find code.

    I’ll take a closer look at that second link, but I’m still hoping to find a step-by-step so that I can understand how to create a menu instead of just coping another theme. I’m trying to go beyond being a hacker, and actually learn. ??

    Thread Starter get_username

    (@get_username)

    Thanks, WPyogi. These resources are very helpful. I appreciate the reply. The site seems to work after removing that rogue code, but I will definitely run a full scan.

    Thread Starter get_username

    (@get_username)

    Hey Steven. I agree my nomenclature could have been a little better, and I have a page called Testimonials to add to that.

    From what I can see, I have a post type label named Testimonials(plural) and Testimonial(singular). The actual post type name is “clientfeedback”. My taxonomy is called “testimonial.”

    Clear as mud, right? I can get my posts to show on my Testimonials page, it’s the taxonomy link that does not work. So I believe I do need the taxonomy page. It’s the same as when you click on a category link when browsing a standard blog. You click the category that the post is associated with, and you’re taken to /category/%postname%. In my case, I’m looking for /taxonomy/%postname%.

    UPDATE: After posting this question on another forum, someone mentioned that I needed to re-save my permalinks again. I did this, and so far this has worked. A little more testing is needed, but I think this might have been part of a problem I was not even aware of. Has anyone heard of this? Where does WordPress documentation state that you need to “save permalinks after creating a custom taxonomy?”

    Thread Starter get_username

    (@get_username)

    I should also note that this is the code I’m using to bring up custom taxonomy link.

    <?php the_terms( $post->ID, 'testimonial', '<strong>Posted in:</strong> ', ', ', ' ' ); ?>

    Could this have anything to do with it?

    Thread Starter get_username

    (@get_username)

    Thanks, RoseAndMoon, I’ve tried what they mentioned in that post. I have taxonomy-testimonial.php as my template, but it skips right to the index.php file. My registered taxonomy is of course “testimonial.”

    Thread Starter get_username

    (@get_username)

    Here is my code if you think that will help. Any ideas you might have is greatly appreciated. This is the last portion of the site and then I’m done.

    // testimonial custom content type
    add_action('init', 'testimonial_register');
    
    function testimonial_register() {
    
    	$labels = array(
    		'name' => _x('Testimonials', 'post type general name'),
    		'singular_name' => _x('Testimonial', 'post type singular name'),
    		'add_new' => _x('Add New', 'testimonial item'),
    		'all_items' => __('All Testimonials'),
    		'add_new_item' => __('Add New Testimonial'),
    		'edit_item' => __('Edit Testimonial'),
    		'new_item' => __('New Testimonial'),
    		'view_item' => __('View Testimonial'),
    		'search_items' => __('Search Testimonials'),
    		'not_found' =>  __('Nothing found'),
    		'not_found_in_trash' => __('Nothing found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => 6,
    		'supports' => array('title','editor','thumbnail'),
    		'has_archive' => true
    	  ); 
    
    	register_post_type( 'clientfeedback' , $args );
    }
    ?>
    <?php
    // testimonial custom taxonomy
    add_action('init', 'testimonial_taxonomies', 0);
    
    function testimonial_taxonomies() {
    
      $labels = array(
        'name' => _x( 'Testimonial Types', 'taxonomy general name' ),
        'singular_name' => _x( 'Testimonial Type', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Testimonial Types' ),
        'all_items' => __( 'All Testimonial Types' ),
        'parent_item' => __( 'Parent Testimonial Type' ),
        'parent_item_colon' => __( 'Parent Testimonial Type:' ),
        'edit_item' => __( 'Edit Testimonial Type' ),
        'update_item' => __( 'Update Testimonial Type' ),
        'add_new_item' => __( 'Add New Testimonial Type' ),
        'new_item_name' => __( 'New Testimonial Type Name' ),
        'menu_name' => __( 'Testimonial Types' ),
    	); 
    
    register_taxonomy(
    	'testimonial', // internal name = machine-readable taxonomy name
    	'clientfeedback', // object type = post, page, link, or custom post-type
    		array(
    		'hierarchical' => true, // true for hierarchical like cats, false for flat like tags
    		'labels' => $labels, // the human-readable taxonomy name
    		'query_var' => true, // enable taxonomy-specific querying
    		'rewrite' => true // pretty permalinks for your taxonomy?
    	));
    }
    ?>
Viewing 15 replies - 1 through 15 (of 68 total)