【问题标题】:Wordpress Portfolio: Featured Image inline with title and metaWordpress Portfolio:带有标题和元数据的特色图片
【发布时间】:2018-11-23 10:02:29
【问题描述】:

首先,我相当缺乏经验——尤其是 PHP。任何指导将不胜感激。

我正在尝试自定义 Wordpress 投资组合帖子页面。我希望帖子标题和元数据显示在特色图片的内联和右侧。

我尝试使用纯 CSS 来完成此操作,添加“display:inline-block”并浮动图像和标题。这不起作用,所以我假设我需要编辑 php 模板 (content-portfolio.php),但不知道该怎么做。

再次,我们将不胜感激任何指导。非常感谢!

现在存在的 content-portfolio.php 文件是:

<?php

// =============================================================================
// VIEWS/INTEGRITY/CONTENT-PORTFOLIO.PHP
// -----------------------------------------------------------------------------
// Portfolio post output for Integrity.
// =============================================================================

$archive_share = x_get_option( 'x_integrity_portfolio_archive_post_sharing_enable' );

?>



<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  <div class="entry-featured">
    <?php x_portfolio_item_featured_content(); ?>
  </div>
  <div class="entry-wrap cf">

    <?php if ( x_is_portfolio_item() ) : ?>

      <div class="entry-info">
        <header class="entry-header">
          <h1 class="entry-title entry-title-portfolio"><?php the_title(); ?></h1>
          <?php x_integrity_entry_meta(); ?>
        </header>
        <?php x_get_view( 'global', '_content', 'the-content' ); ?>
      </div>
      <div class="entry-extra">
        <?php x_portfolio_item_tags(); ?>
        <?php x_portfolio_item_project_link(); ?>
        <?php x_portfolio_item_social(); ?>
      </div>


     <?php else : ?>

      <header class="entry-header">
        <h2 class="entry-title entry-title-portfolio">
          <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php x_the_alternate_title(); ?></a>
        </h2>
      </header>
        <?php x_get_view( 'global', '_content' ); ?>

    <?php endif; ?>

  </div>
</article>

【问题讨论】:

    标签: php css wordpress post portfolio


    【解决方案1】:

    我不知道你的意思是在 h1 行中同时包含两者:

    <h1 class="entry-title entry-title-portfolio"><?php the_title(); x_integrity_entry_meta();?></h1>
    

    您也可以尝试将 entry-header 样式更改为.entry-header{display:flex}

    【讨论】:

    • 感谢您的回复!我试过这个,它使元与标题内联,但不是图像。我可能没有正确解释我想要达到的目标。一个很好的例子可以在这里看到:medium.com/s/trustissues/…。帖子标题和信息在图片旁边。知道如何实现这一目标吗?谢谢!
    • 嗯,你现在说的是问题中需要的信息,所以如果你看到下一张图片,你会看到有一个父 div(绿色)包含 2 个孩子(红色和橙色)这个parent 正如我之前提到的那样应用了 flex 属性,并且根据内容它会根据需要对齐,这是我所说的颜色的图片box.magc.co/index.php/s/OpxnQaR8EGhfS0F
    【解决方案2】:

    你可以用纯 css 做到这一点。

    您需要为标题“.entry-header”分配特定宽度。

    还将“display:inline”分配给“.entry-title-portfolio”和包装您的元内容的标签。

    header.entry-header { width: 100%; }
    h1.entry-title-portfolio { display: inline; }
    [your meta class] { display: inline; }
    

    【讨论】:

    • 感谢您的回复!我试过这段代码,但它没有改变任何东西。我可能没有正确解释我想要实现的目标 - 可以在此处看到一个示例:medium.com/s/trustissues/...。帖子标题和信息在图片旁边。知道我还能尝试什么吗?再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2014-08-07
    • 2022-10-20
    • 2015-04-05
    • 2014-09-28
    • 2014-11-02
    • 2014-02-16
    • 1970-01-01
    • 2012-10-12
    相关资源
    最近更新 更多