WordPress.org

Ready to get started?Download WordPress

Forums

Open portfolio in a new tab. (21 posts)

  1. ihpalash
    Member
    Posted 1 year ago #

    Hello, Does any one knows how to open portfolio post in a new tab?
    the post and the port folio post are different from each other.Though they work same. Used many plug in but not working as there's a hover effect on the thumbnail. As i am no good in code, i give you my .php files. please tell me where to put target="_blank" . thanks
    ----------------single-portfolio.php----------------------

    <?php get_template_part('templates/page', 'header_work'); ?>
    
    <div class="row">
      <div id="portfolio-page" class="clearing-container">
          <?php get_template_part('templates/portfolio', 'single'); ?>
      </div>
    </div>

    ------------------------page.php--------------------

    <?php
    
        get_template_part('templates/page', 'header');
    
        ?>
    
    <div class="row">
    
        <?php
        if(!is_front_page()) {
            set_layout('pages');
        } else {
            echo '<div id = "content" class = "fifteen columns" ><div class = "row" >';
        }
    
        get_template_part('templates/content', 'page');
    
        echo '</div>';
    
        if(!is_front_page()){
            set_layout('pages', false);
        } else {
            echo '</div></div>';
        }
    
        ?>
    
    </div>

    --------------------single.php-------------------------

    <?php get_template_part('templates/page', 'header'); ?>
    
    <div class="row">
    
        <?php
        $post_display = get_post_meta($post->ID, 'full_width_post', true);  ;
    
        if( !$post_display || $post_display == 'default' ) {
            set_layout('single', true);
        } else {
            if (($post_display == "2c-l-fixed") || ($post_display == "3c-fixed") || ($post_display == "3c-l-fixed")) {
                get_template_part('templates/sidebar', 'left');
            }
            if ($post_display == "3c-l-fixed"){
                get_template_part('templates/sidebar', 'right');
            }
    
            if (($post_display == "2c-l-fixed") || ($post_display == "2c-r-fixed")) {
                echo '<div id="content" class="eleven columns">';
            } elseif (($post_display == "1col-fixed")) {
                echo '<div id="content" class="fifteen columns">';
            } else {
                echo '<div id="content" class="seven columns">';
            }
        }
    
        get_template_part('templates/content', 'single');
    
        if( !$post_display || $post_display == 'default' ) {
            set_layout('single', false);
        } else {
            if ($post_display == "3c-r-fixed") {
                get_template_part('templates/sidebar', 'left');
            }
            if (($post_display == "2c-r-fixed") || ($post_display == "3c-fixed") || ($post_display == "3c-r-fixed")) {
                get_template_part('templates/sidebar', 'right');
            }
        }
        ?>
    </div>

    -----------------------------functions.php------------------------

    <?php
    /**
     * Roots functions
     */
    
    if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); }
    
    require_once locate_template('/inc/includes.php');   
    
    function roots_setup() {
    
      // Make theme available for translation
      load_theme_textdomain('roots', get_template_directory() . '/lang');
    
      // Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
      register_nav_menus(array(
        'primary_navigation' => __('Primary Navigation', 'roots'),
      ));
    
      // Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
      add_theme_support('post-thumbnails');
    
      // Add post formats (http://codex.wordpress.org/Post_Formats)
      add_theme_support('post-formats', array('gallery', 'link', 'image', 'quote', 'video', 'audio'));
    
      // Tell the TinyMCE editor to use a custom stylesheet
      add_editor_style('assets/css/editor-style.css');
    
    }
    
    add_action('after_setup_theme', 'roots_setup');
    
    add_post_type_support('page', 'excerpt');
    
    add_action( 'admin_notices', 'is_options_css_writable' );
    function is_options_css_writable(){
        if( !is_writable( locate_template('/css/options.css') ) )
            echo '<div class="updated"><p>css/options.css rights is not enough</p></div>';
    }
    
    add_filter( 'the_category', 'add_nofollow_cat' );
    function add_nofollow_cat( $text ) {
        $text = str_replace('rel="category tag"', "", $text); return $text;
    }
    
    add_filter('widget_text', 'do_shortcode');
    
    function limit_words($string, $word_limit) {
    
        // creates an array of words from $string (this will be our excerpt)
        // explode divides the excerpt up by using a space character
    
        $words = explode(' ', $string);
    
        // this next bit chops the $words array and sticks it back together
        // starting at the first word '0' and ending at the $word_limit
        // the $word_limit which is passed in the function will be the number
        // of words we want to use
        // implode glues the chopped up array back together using a space character
    
        return implode(' ', array_slice($words, 0, $word_limit));
    
    }
    
    add_filter( 'wp_get_attachment_image', 'remove_thumbnail_dimensions', 10 );
    add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
    
    function remove_thumbnail_dimensions( $html ) {
        $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
        return $html;
    }
    
    // show admin bar only for admins
    if (!current_user_can('manage_options')) {
        add_filter('show_admin_bar', '__return_false');
    }
    // show admin bar only for admins and editors
    if (!current_user_can('edit_posts')) {
        add_filter('show_admin_bar', '__return_false');
    }
    
    function template_admin_head(){
        echo '<script>template_uri = "'.get_template_directory_uri().'";</script>';
        echo '<script>base_url = "'.home_url().'";</script>';
    }
    add_action('admin_head', 'template_admin_head');

    ----------------content-single.php----------------------------

    <?php
    global $NHP_Options;
    
    if (!have_posts()) : ?>
      <div class="alert alert-block fade in">
        <p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
      </div>
        <?php get_search_form(); ?>
    <?php endif; ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
        <?php
        global $NHP_Options;
        if( $NHP_Options->get("post_inner_header") == '1'){
    
        echo '<header style = "margin-left: 0; min-height: auto">';
            get_template_part('templates/entry-meta','single');
        echo '</header>';
        }
    
        if( $NHP_Options->get("post_share_button") && (($NHP_Options->get("post_share_place") == 'top' )|| ($NHP_Options->get("post_share_place") == 'both' ))) { ?>
    
            <?php get_template_part('/templates/social', 'share'); ?>
    
            <?php  }
    
        if ($NHP_Options->get("thumb_inner_disp") == '1') {
            if (has_post_thumbnail()) {
                $thumb = get_post_thumbnail_id();
                $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL
                if ($NHP_Options->get('post_thumbnails_width') != '' && $NHP_Options->get('post_thumbnails_height') != '') {
                    $article_image = aq_resize($img_url, $NHP_Options->get('post_thumbnails_width'), $NHP_Options->get('post_thumbnails_height'), true);
                } else {
                    $article_image = aq_resize($img_url, 1200, 500, true);
                }
                ?>
                <div class="entry-thumb">
                    <a href="<?php the_permalink(); ?>"><img src="<?php echo $article_image ?>"  alt="<?php the_title(); ?>"/></a>
                </div>
                <?php
            }
        }
        ?>
    
        <div class="entry-content">
    
        <?php if (has_post_format('video')) {
    
            get_template_part('templates/single-post', 'video');
        }?>
    
            <?php the_content(); ?>
    
        </div>
    
      </article>
    <?php    if( $NHP_Options->get("autor_box_disp") =='1'){
    
            get_template_part('/templates/author', 'box');
    
        }
        if( $NHP_Options->get("post_share_button") && (($NHP_Options->get("post_share_place") == 'bottom' )|| ($NHP_Options->get("post_share_place") == 'both' ))) {
    
            get_template_part('/templates/social', 'share');
    
          }
    
        endwhile;  comments_template('/templates/comments.php'); ?>
    
    </div>
  2. hiphopinenglish
    Member
    Posted 1 year ago #

    Do you not have a template that has portfolio in the name?

  3. ihpalash
    Member
    Posted 1 year ago #

    Do you not have a template that has portfolio in the name?

    Can you be more specific, didn't understand your answer.

  4. Bea Cabrera
    Member
    Posted 1 year ago #

    He meant for you to search for a file on our root directory named template-portfolio.php or something similar.

    Either way, if I get wat you want, you'd like the link from the menu to open on a new tab, right? That is something you can't do that easily (please correct me if I'm wrong!). The 'target' attribute is for an html 'a' tag. More precisely, the 'a' tag that is linking your portfolio item in the menu.

    This menu may be hardcoded in your theme, this is possible, in this case it would be most probably located in your 'header.php'. But if you create this menu from the Menu option in WordPress... then I don't how is one able to modify this 'a' tag without modifying core WordPress functions.

    This is an interesting question and I would like to know if there is perhaps a function for our theme's functions file to overload, and be able to add a target attribute to links from the menu.

    Thanks!

  5. ihpalash
    Member
    Posted 1 year ago #

    The whole time I was looking at your avatar, any way, I wasn't trying to open menu items in new tab i was trying to open post/portfolio in the new tab . thanks for comment @bea cabera

  6. Bea Cabrera
    Member
    Posted 1 year ago #

    Oh! You mean from inside the loop then! I thought you meant opening the portfolio page on a different tab because this is how I have it. You're lucky, that's easier then.

    Basically, you'll have to put it inside the 'a' tag from the loop of your blog or portfolio loop (wherever this is). But that is none from the files you posted. That's why @hiphopinenglish asked for the portfolio template file. Typically you will have something named content.php (this is in the twentytwelve theme). Look for something like:

    <h1 class="entry-title">
    	<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    </h1>

    That's your 'a' tag!

    Rewrite:

    <a href="<?php the_permalink(); ?>" target="_blank" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>

    cheers!

    P.S.: What's wrong with my avatar? :S

  7. ihpalash
    Member
    Posted 1 year ago #

    This is weird, I got the content.php file but I have " like two functions. don't know what to edit.
    My whole content.php

    <?php global $NHP_Options; ?>
    <div id="main">
        <?php if (!have_posts()) : ?>
    
      <div class="alert alert-block fade in">
        <div class="messagebox_text">
          <p> </p>
          <h2><?php _e('Sorry, no results were found.', 'roots'); ?></h2>
        </div>
      </div>
    
        <?php get_search_form(); ?>
        <?php endif; ?>
    
        <?php while (have_posts()) : the_post(); ?>
    
      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <time class="updated" datetime="<?php echo get_the_time('c'); ?>" pubdate>
          <span class="day"><?php echo get_the_date('d'); ?></span>
          <span class="mounth"><?php echo get_the_date('M'); ?>.</span>
          <span class="time"><?php the_time('g:i a'); ?></span>
        </time>
    
        <header>
            <?php get_template_part('templates/entry-meta'); ?>
          <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        </header>
    
          <?php
    
          if ( has_post_format( 'video' ) || has_post_format( 'gallery' )) {
    
          } else {
    
          if (has_post_thumbnail()) {
              $thumb = get_post_thumbnail_id();
              $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL
                if ($NHP_Options->get('post_thumbnails_width') !='' && $NHP_Options->get('post_thumbnails_height') !=''){
                    $article_image = aq_resize($img_url, $NHP_Options->get('post_thumbnails_width'), $NHP_Options->get('post_thumbnails_height'), true);
                } else {
                    $article_image = aq_resize($img_url, 1200, 500, true);
                }
              ?>
            <div class="entry-thumb">
              <a href="<?php the_permalink(); ?>"><img src="<?php echo $article_image ?>" alt="<?php the_title(); ?>"/></a>
            </div>
              <?php }}?>
    
        <div class="entry-content">
    
            <?php global $data;  echo $data['type_posts_show']; if ($data['type_posts_show'] == 'full_post') {
                the_content('');
             } else {
            if ( has_post_format( 'gallery' )) {
                get_template_part('templates/post', 'gallery');
            }if ( has_post_format( 'link' )) {
                get_template_part('templates/post', 'link');
            }if ( has_post_format( 'image' )) {
                get_template_part('templates/post', 'image');
            }if ( has_post_format( 'quote' )) {
                get_template_part('templates/post', 'quote');
            }if ( has_post_format( 'video' )) {
                get_template_part('templates/post', 'video');
            }if ( has_post_format( 'audio' )) {
                get_template_part('templates/post', 'audio');
            }else {
                $format = get_post_format();
                if ( false === $format ) {
              echo '<p>';
                the_excerpt('');
              echo '</p>';
                }
            }}?>
    
        </div>
    
      </article>
    
        <?php endwhile; ?>
    
        <?php if ($wp_query->max_num_pages > 1) : ?>
    
        <?php if ($NHP_Options->get('pagination_style') == '2') { ?>
    
            <nav id="post-nav" class="page-numb">
                <?php if (function_exists('wp_corenavi')) wp_corenavi(); ?>
            </nav>
    
            <?php } else { ?>
    
            <nav id="post-nav" class="page-nav">
                <?php next_posts_link(__('<span>Older</span>', 'roots')); ?>
                <?php previous_posts_link(__('<span>Newer</span>', 'roots')); ?>
            </nav>
    
        <?php } endif; ?>
    
    </div>

    Please have a look. And help me which one should I put the blank tag.

    P.S.: What's wrong with my avatar? :S

    Why you guys always take everything in negative. I was telling you are beautiful. <3 <3

  8. ihpalash
    Member
    Posted 1 year ago #

    Hm, I have put both the target-"_blank" but still not worKing

  9. Bea Cabrera
    Member
    Posted 1 year ago #

    See the header section?

    The line:
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

    That should be:
    <h2><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></h2>

  10. ihpalash
    Member
    Posted 1 year ago #

    nope not working.

  11. Bea Cabrera
    Member
    Posted 1 year ago #

    Then you must be getting your posts from somewhere else.

    Any template? We need more info.

  12. ihpalash
    Member
    Posted 1 year ago #

    http://www44.zippyshare.com/v/13860294/file.html
    I have uploaded the template. Please see.. thanks

  13. hiphopinenglish
    Member
    Posted 1 year ago #

    Which of the Portfolio views are you using?

    In your theme, you have multiple "portfolio" templates. We need to know which one you're using.

    It COULD be: portfolio-normal-2.col or portfolio-normal-4-col

    If you have a working website (not local), you could help us by sharing the link too.

  14. ihpalash
    Member
    Posted 1 year ago #

    Sir, if you see my theme, then you can also see that a cover comes up when one point his mouse on the post/portfolio. try to maKe a demo post/portfolio and publish it to the home page. there you can get all your answers.
    I am not familiar what you are telling as all 2/4 col doesn't need cause I am designing for my need not with that the theme recommended for me.
    Try post something with this theme and I hope you will find the answer. and many many thanks for commenting

  15. hiphopinenglish
    Member
    Posted 1 year ago #

    Sorry, but I haven't got the time to install this theme and try it out. Maybe @Bea Cabrera has

  16. Bea Cabrera
    Member
    Posted 1 year ago #

    I certainly not. @ihpalash I'm willing to help you out, but you must know what template you are using for the loop of posts/portfolio items. Perhaps "the homepage" ? Where does the code for "the homepage" come from? Which file in particular? Check that and paste the content of THAT file here. I'm sorry but I work and have no time (and I'm not willing) to install your theme, change my own wordpress installation theme to it and play with it. Please understand.

  17. ihpalash
    Member
    Posted 1 year ago #

    I like your straight forward. Any way recently i was checking wp forum topics in google and alas i found this one in no. one. though it's not solved. :P
    I made a page and made it my static home page. And i am designing it with Visual composer, css, jquery, and with many short codes. I am very close to finish, then I got this headache that the posts are not opening in a new tab.
    The post are being delivered from a short code, but it's doing fine as What it should do. Any way, I think it would be better if I publish my site to live server in spite of seeking help from you guys, You been so help full to me from the beginning. No word can express my feelings, love, respect for you guys. @bea Cabera @ hiphopinenglish.

  18. ihpalash
    Member
    Posted 1 year ago #

    I like your straight forward. Any way recently i was checking wp forum topics in google and alas i found this one in no. one. though it's not solved. :P
    I made a page and made it my static home page. And i am designing it with Visual composer, css, jquery, and with many short codes. I am very close to finish, then I got this headache that the posts are not opening in a new tab.
    The post are being delivered from a short code, but it's doing fine as What it should do. Any way, I think it would be better if I publish my site to live server in spite of seeking help from you guys, You been so help full to me from the beginning. No word can express my feelings, love, respect for you guys. @bea Cabera @ hiphopinenglish.

  19. Bea Cabrera
    Member
    Posted 1 year ago #

    So you have created a page and made it a static home page... ok... what template (look on the right hand side when editing the page)? Your theme has tons of templates.

    I'm not installing it but I looked through it... could it be portfolio.php? templates/content-grid.php the file you need to change?

    I'm sorry we can't do any more, but you're pretty near your goal.

  20. hiphopinenglish
    Member
    Posted 1 year ago #

    Let us know the link when you have a live site, and we'll have a look at that. It might be easier to see where "target_blank" will need to be added.

  21. ihpalash
    Member
    Posted 1 year ago #

    thanks. It's "default template" when I see the right side of my screen. @bea

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.