Forum Replies Created

Viewing 15 replies - 16 through 30 (of 57 total)
  • Thread Starter lgehrig4

    (@lgehrig4)

    Part of my theme. In my menu the ‘About’ and ‘Services’ just taken me to a section of the home page. I set the scroll-behavior: smooth in the html of my css and that’s pretty much the extent of it.

    I would like for that behavior to stay but also be able to get to those sections from other pages. In order to do that I have to point the menu links to the home page and then to the section, but when I am on the home page and click on those links the page reloads instead of just scrolling smoothly to the section.

    I’m wondering if I could somehow set a condition to do one or the other depending on the page you are on. Or I guess I could create separate menu to display on all other pages accept the home page? Can that be done?

    Thread Starter lgehrig4

    (@lgehrig4)

    This!

    If you want to develop your own code for the learning experience, I think it’s a great way to learn. One challenge you’ll face is the APIs for various social sites are all going to be different. To interact with each site’s API, you’ll likely need separate, dedicated code for each. However there could be certain common elements, so that modularizing your code could save you from some redundancy

    The purpose of what I am doing is to learn while creating this theme. Can you point me to good resources on how to start this?

    Is this a good reference?

    https://developer.wordpress.com/docs/api/1/get/meta/sharing-buttons/

    Thread Starter lgehrig4

    (@lgehrig4)

    Yes, that was it. Didn’t even think to revisit that after I had deleted the page and replaced it. At least I know this for the future. Thx!

    Thread Starter lgehrig4

    (@lgehrig4)

    Thank you. I actually came across this before. By posting it as your reply are you inferring that that is the only way to do it or the best way? I ask because I’m trying to get as much experience building the site in php, but if this is the way to go then so be it.

    Thread Starter lgehrig4

    (@lgehrig4)

    So, I now everything works the way I want it to, but I’m not sure if it is “proper wordpress’.

    Aside from your other typical site pages (about, home, etc) I have both default posts(blog) and custom posts (portfolio). I also created a custom taxonomy (projects).

    home.php -> blog archive
    archive-portfolio.php -> portfolio archive
    single.php -> single blog post
    single-portfolio.php -> single portfolio post
    category.php -> blog posts queried by category
    index.php -> portfolio posts queried by category

    Trying to get the portfolio (custom) posts to query by category has been whats giving me fits. Finally I got to the point where it kept defaulting to index.php so I just made that the page.

    Next problem was that all the portfolio posts were displaying on index.php and not just the ones with the category that was queried. I was using WP_Query for the loop because thats what I read what required for custom posts. For the heck of it I removed all that and just used if ( have_posts() ) : while ( have_posts() ) : the_post(); like the default posts and now it displays just the queried custom posts.

    I’m happy that it works but I wish I knew why.

    Thread Starter lgehrig4

    (@lgehrig4)

    Update: I took the easy way out. Created a new instance/database and copied all the files over.

    I would still like to understand what I may have done, and even try to fix the old site if anyone has suggesstions.

    Thread Starter lgehrig4

    (@lgehrig4)

    @bcworkz First, thank you for taking the time to educate me on this topic. There is a lot for me to learn and I will certainly focus on those links you posted.

    Since my last post I have switch directions. I created a custom taxonomy for the custom posts and I will use a different category page for those, I just need to figure out how to get the template to point to the page.

    I actually screwed up something while trying to clean up my database and now I have another issue which I’ll create a separate post for. Pain in the **s, but I’m sure the process of getting it rectified will benefit me going forward.

    Thread Starter lgehrig4

    (@lgehrig4)

    @bcworkz Sensei, I’m still only a white belt. I understand what you wrote, but am still lost as to how I execute it. If you would be so kind as to provide a little direction on how I can pass this query string it would be greatly appreciated!

    Thread Starter lgehrig4

    (@lgehrig4)

    I’m getting closer, but I still need help. Found out that category.php was intended just for posts and that I needed to add this so that it queried custom post types

    function add_cpt_to_category_archive( $query ) {
      if ( ! is_admin() && $query->is_main_query() ) {
        if ( is_archive() || is_category() ) {
          // Add CPT to the category
          $query->set( 'post_type', array( 'post', 'portfolio' ) );
        }
        if ( $query->is_search() ) {
          // Add CPT to the search
          $query->set( 'post_type', array( 'post', 'portfolio' ) );
        }
      }
    }
    add_action('pre_get_posts', 'add_cpt_to_category_archive' );    

    Now when I click on a category on either POST or CUSTOM POST TYPE I get all that have this category. That’s a step in the right direction but now I need to configure and IF statement so that it just displays either the category results for either my POST’s or CPT’s.

    Thread Starter lgehrig4

    (@lgehrig4)

    Ok, so I sort of isolated the issue by setting the if statement for each post type individually.

    For the posts it works as it should. While on the post page I click on a category and it takes me to the category.php template displaying the posts with that category.

    For the portfolio posts I use the code below and it takes me to the right template, but it displays ALL of the portfolio posts, not just the ones related to the selected category.

    This is the code I use for the portfolio posts:

    $args = array('post_type' => 'portfolio');
    $portfolio = new WP_Query( $args );
          
    if ( $portfolio->have_posts() ) : while ( $portfolio->have_posts() ) : $portfolio->the_post();  

    What would be reason the selected category doesn’t apply to these posts? Also, how do I construct the if statement to load either the regular posts or portfolio posts?

    Here is the code initallizing the custom post type:

    function custom_post_type() {
      
        $labels = array( 
            'name' => 'Portfolio',  
            'singular_name' => 'Project', 
            'add_new_item' => 'Add New Project', 
            'edit_item' => 'Edit Project',
            'all_items' => 'All Projects',
            'new_item' => 'New Project',
            'view_item' => 'View Portfolio',
            'search_item' => 'Search Portfolio',
            'not_found' => 'No projects found',
            'not_found_in_trash' => 'No products found in trash',
            'parent_item_colon' => 'Parent Item'
        );
        $args = array(
          'rewrite' => array('slug' => 'portfolio'),
          'labels' => $labels,
          'public' => true,
          'has_archive' => true,
          'publicly_queryable' => true,
          'query_var' => true,
          'capability_type' => 'post',
          'hierarchical' => false,
          'supports' => array(
            'title', 
            'thumbnail', 
            'editor', 
            'excerpt',
            'revisions'
          ),
          'taxonomies' => array( 'category', 'post_tag' ),
          'menu_position' => 4, // position where this is located in admin panel
          'exclude_from_search' => false,
          'menu-icon' => 'dashicons-clipboard' // wordpress icons
        );
       
        register_post_type('portfolio', $args);
    }
    
    add_action('init', 'custom_post_type');
    Thread Starter lgehrig4

    (@lgehrig4)

    @mcmwebsol Perfect! thank you

    Thread Starter lgehrig4

    (@lgehrig4)

    @sterndata I thought one of the purposes of a child theme was that you don’t lose your customizations when the theme is updated?

    Thread Starter lgehrig4

    (@lgehrig4)

    @sterndata Sorry to summon you back to this. I realize this last question may be more of a ‘fixing wordpress’ topic, but I didn’t want to start another thread since we’ve already done in depth here:)

    I ended up pasting the Font Kit’s CSS content into the CSS file that was already inside the child theme and everything is working. Below this content I’m just setting the fonts globally like this and it’s working fine

    h1, h2, h3, h4, h5, h6 {
    	font-family: 'Campton-bold' !important;
    }

    Do you see any problem in doing it this way? My thoughts are that if it is all done inside the theme directory itself that I can lose this when the theme is updated.

    I arrived at this thread because I too need to edit a plugin file. I copied that file to my child theme and I was hoping to find a way to get that file to override the plugin’s direct file.

    The OP says that he’s doing the same and that it’s working for him but is asking if there was a better way to organize these files.

    @sterndata tells the OP that the method that is already working for him won’t work.

    @joyously tells him that he should make your changes in his own plugin (specific to that site), not a child theme.

    I’m so confused now. Whether it works or not should we NOT be copying plugin files into the child theme folder? If this is the case, joy can you please elaborate a little further on your explanation? How do you make your own plugin? How do you get it to extend core or plugins? Where does this directory sit?

    Sorry for all the questions, but I’d really love to get this task completed.

    Thread Starter lgehrig4

    (@lgehrig4)

    @bcworkz

    I located the plugin file that generates the cards for that page and I copied it to the child theme. Now I just need to figure out how to override the plugin’s template with mine. I think this commented out section is the info that I am looking for. If that’s the case perfect!

    <?php
        global $post, $more, $aux_content_width;
        $more = 0; // to enable read more tag
    
        // the image width is 63% of wrapper
        $media_width = $aux_content_width * 0.63;
        $image_aspect_ratio = 0.65;
    
        $post_vars   = auxpfo_get_portfolio_config( $post, array(
            'request_from'       => 'archive',
            'media_width'        => $media_width,
            'media_size'         => 'large',
            'upscale_image'      => true,
            'crop'               => true,
            'add_image_hw'       => true,
            'image_sizes'        => array(
                array( 'min' => '', 'max' => '1024px', 'width' => '100vw' ),
                array( 'min' => '', 'max' => '',       'width' => $media_width.'px' )
            ),
            'srcset_sizes'  => array(
                array( 'width' =>     $media_width, 'height' =>     $media_width * $image_aspect_ratio ),
                array( 'width' => 2 * $media_width, 'height' => 2 * $media_width * $image_aspect_ratio ),
                array( 'width' => 4 * $media_width, 'height' => 4 * $media_width * $image_aspect_ratio )
            )
         ) );
        extract( $post_vars );
    
        // Add class name for custom styles
        $land_item_class_name = auxin_get_option( 'show_portfolio_land_side_entry_box_colors' ) ? ' aux-item-land' : '';
    
    ?>
                            <article <?php post_class( 'aux-single-portfolio-wrapper aux-portfolio-land' . $land_item_class_name ); ?> >
                                <?php if ( $has_attach ) { ?>
                                <div class="entry-media">
                                    <?php echo $the_media; ?>
                                </div>
                                <?php
                                   }else { ?>
                                        <div class="entry-media">
                                            <div class="aux-media-frame aux-media-image">
                                                <a href="<?php echo !empty( $the_link ) ? $the_link : get_permalink(); ?>">
                                                    <img src="<?php  echo AUXIN_URL . 'images/welcome/image-frame.svg'; ?>" class="auxin-attachment auxin-featured-image attachment-1024x1024" alt="portfolio default image" >
                                                </a>
                                            </div>
                                        </div>
                                <?php   }
                                ?>
                                <div class="aux-land-side">
                                    <div class="entry-main">
    
                                        <header class="entry-header">
                                            <h3 class="entry-title">
                                                <a href="<?php echo !empty( $the_link ) ? $the_link : get_permalink(); ?>">
                                                    <?php echo !empty( $the_name ) ? $the_name : get_the_title(); ?>
                                                </a>
                                            </h3>
                                        </header>
    
                                         <div class="entry-content">
                                            <?php
    
                                               // $content_listing_type   = is_category() || is_tag() ? auxin_get_option( 'post_taxonomy_archive_content_on_listing' ) : auxin_get_option( 'blog_content_on_listing' );
                                              //  $content_listing_length = is_category() || is_tag() ? auxin_get_option( 'post_taxonomy_archive_on_listing_length', 255 ) : auxin_get_option( 'excerpt_len', 255 );
    
                                                // get overview context
                                                $_overview = auxin_get_post_meta( $post, '_overview' );
    
                                                if( has_excerpt() ) {
                                                    the_excerpt();
                                                } elseif( ! empty( $_overview )  ){
                                                    auxin_the_trimmed_string( auxin_strip_shortcodes( auxin_extract_text( $_overview ) ), 170 );
                                                }
    
                                            ?>
                                        </div>
                                    </div>
    
                                    <footer class="entry-meta">
                                        <div class="portfolio-tax">
                                            <span class="entry-tax">
                                            <?php // the_category(' '); we can use this template tag, but customizable way is needed! ?>
                                            <?php $tax_name = 'portfolio-cat';
                                                  $cat_terms = wp_get_post_terms( $post->ID, $tax_name );
                                                  if( $cat_terms = wp_get_post_terms( $post->ID, $tax_name ) ){
                                                      foreach( $cat_terms as $term ){
                                                          echo '<a href="'. get_term_link( $term->slug, $tax_name ) .'" title="'.__("View all posts in ", 'auxin-portfolio'). $term->name .'" rel="category" >'. $term->name .'</a>';
                                                      }
                                                  }
                                            ?>
                                            </span>
                                            <?php if( ! empty($cat_terms) ){
                                                edit_post_link(__("Edit", 'auxin-portfolio'), '<i> | </i>', '');
                                                } else {
                                                    edit_post_link(__("Edit", 'auxin-portfolio'), '', '');
                                                }
                                            ?>
                                        </div>
                                        <?php
                                        if( function_exists('wp_ulike') && auxin_get_option( 'show_portfolio_archive_like_button' ) ) { ?>
                                            <div class="comments-iconic">
                                                <?php
                                                    wp_ulike( 'get', array( 'style' => 'wpulike-heart', 'button_type' => 'image', 'wrapper_class' => 'aux-wpulike aux-wpulike-portfolio-widget' ) );
                                                ?>
                                            </div>
                                        <?php  } ?>
    
                                    </footer>
    
                                </div>
    
                            </article>

    I think this link has the info I need to override the plugin template, but it’s a bit above my head currently. Seems to be exactly what I’m looking to accomplish though.

    https://deliciousbrains.com/wordpress-plugin-development-template-files/

Viewing 15 replies - 16 through 30 (of 57 total)