What's the right code

Messing with custom posts and want to get a page to display some posts from that topic

The article regarding doing it for this theme, divi says


You will need to modify the loop by adding the following code:

<?php
$query = new WP_Query( array('post_type' => 'movie-reviews', 'posts_per_page' => 5 ) );
while ( $query->have_posts() ) : $query->the_post(); ?>
// Your code e.g. "the_content();"
<?php endif; wp_reset_postdata(); ?>
<?php endwhile; ?>

The code relating to this on the page already is

<?php while ( have_posts() ) : the_post(); ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

I remove it and paste the code it says but doesn't work.

:(
 
No that doesn't seem to be the case, here's a bigger snippet of the page im trying to paste new code into


<?php /* Template Name: Gifts For Her */ ?>
<?php

get_header();

$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );

?>

<div id="main-content">
<?php if ( ! $is_page_builder_used ) : ?>

<div class="container">
<div id="content-area" class="clearfix">
<div id="left-area">

<?php endif; ?>

<?php while ( have_posts() ) : the_post(); ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php if ( ! $is_page_builder_used ) : ?>

<h1 class="entry-title main_title"><?php the_title(); ?></h1>
<?php
$thumb = '';

$width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );

$height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
$classtext = 'et_featured_image';
$titletext = get_the_title();
$thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
$thumb = $thumbnail["thumb"];

if ( 'on' === et_get_option( 'divi_page_thumbnails', 'false' ) && '' !== $thumb )
print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
?>

<?php endif; ?>
 
Upvote 0

fisicx

Moderator
Sep 12, 2006
46,873
8
15,485
Aldershot
www.aerin.co.uk
Not tested but this should work:

PHP:
<?php $query = new WP_Query( array('post_type' => 'movie-reviews', 'posts_per_page' => 5 ) ); ?>
<?php if($query->have_posts()) : ?>
<?php while($query->have_posts()) : $query->the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>

But don't use divi if at all possible - they add so much junk to their code. The example you gave is appalling. you can create great sites without their page builder.
 
Upvote 0
But don't use divi if at all possible - they add so much junk to their code. The example you gave is appalling. you can create great sites without their page builder.

Absolutely agree, avoid page builder themes if you care about clean, semantic, quick loading efficient code. Page builders are for hobby / enthusiast type websites... in my opinion anyway.
 
Upvote 0
Gonna have to get my guy in palestine to have a look :D, the posts created in the post type aren't displaying with content in them.

I'm gonna take a css course later in the year because i am wanting to set up some affiliate sites, that's why i started using divi actually, because once you get your head around it appears to me to make life easier. I did sort of feel dirty when i first chose it. For now i can't achieve much customising a standard theme.

I know the divi theme has issues, the responsive side could be better. But even so the columns responding / break points appears to be fixable. Part of me thinks web design via platforms like divi is the future.

You say hobbyists, but a hell of a lot of sites are using page builders now, some of the divi sites i've seen look pretty breath taking. And a ton of web designers use them.

When it comes to code i don't really care as long as it doesn't hurt the search rankings. I know this might be something more important in a year or so when google seems as if it will be treating mobile results more seriously, but at the moment i don't notice anything that would affect rankings with divi.

I'd say website builders like go daddy, vista print etc are more the hobby sites now.
 
Upvote 0
You may be right, Im a 20 year web dev veteran.. so am slightly biased haha, i'd guess divi may be a good starting point, but if business takes off, I guarantee you need to dump it as soon as you are able.

No decent sized successful website i've worked on uses these types of themes, but maybe i'm in a bubble.

I'd suggest you learn a little HTML5 and some basic PHP as well as CSS if you want to build your own sites going forward.

Checkout code academy, treehouse and udemy
 
Upvote 0
You may be right, Im a 20 year web dev veteran.. so am slightly biased haha, i'd guess divi may be a good starting point, but if business takes off, I guarantee you need to dump it as soon as you are able.

No decent sized successful website i've worked on uses these types of themes, but maybe i'm in a bubble.

I'd suggest you learn a little HTML5 and some basic PHP as well as CSS if you want to build your own sites going forward.

Checkout code academy, treehouse and udemy

I'll check them out, i do want to learn more. I think there is something in the pre made layouts and sections that will go forward into the future, i think standard ways of coding everything from scratch will become less and less, it's too expensive and time consuming.

I've seen plenty websites made by agencies and free lancers, as things stand with page builders like divi you end up with a nicer looking site and its cheaper. I'd say a lot cheaper.


There's literally tons of stuff out there already you can take and sculpt a little that leaves you with something good enough.
 
Upvote 0
Page builder themes yes - but a theme with Beaver Builder is a different matter.

Isn't beaver builder the same as the elegant themes page builder? I've not really tried using the divi page builder with anything other than divi, as things currently stand it can be pretty buggy using it on divi so i doubt it would be much fun to use on another theme.
 
Upvote 0

fisicx

Moderator
Sep 12, 2006
46,873
8
15,485
Aldershot
www.aerin.co.uk
They aren't the same thing. There are loads of site builders and the elegant themes offering is one of the worst.

The whole problem with Elegant Themes is their out of date approach and poor responsive layouts.

If you want to use Dive that's fine but the code you want you add won't work with their templates without a lot of code rewriitng.
 
Upvote 0

Alan

Free Member
  • Aug 16, 2011
    7,089
    1,974
    Part of me thinks web design via platforms like divi is the future.

    It depends where your target is.

    Definitely at the £400 website for a dog walking business brochure website WordPress is loosing the battle to SquareSpace right now. For two reasons
    1) The page editor is not nice ( for the end user or rapid developer ) to be able to visualise the results ( hence the growth of page builder )
    2) Self hosted wordpress is an 'expensive' activity to do securely and properly ( see the growth of WP specific hosting plans and managed WP services )

    Going forward WordPress is tackling this issues (partly at least) with the Gutenberg Project, which is advancing forward as the core page builder editor. I haven't yet played with it but there is a test version out there.

    What does this mean for the £400 dog walker business brochure website builder - well basically the barrier of entry for developers will continue to drop , and millions of more people will have this great business idea, 'if I can crack out websites to small businesses and I can sell 10 a month I can earn a decent living and call myself a 'web developer''. Not a good time to enter that market!

    However at the £50,000 website / web app end that is a different story.
     
    • Like
    Reactions: Mark_Taylor_
    Upvote 0
    They aren't the same thing. There are loads of site builders and the elegant themes offering is one of the worst.

    The whole problem with Elegant Themes is their out of date approach and poor responsive layouts.

    If you want to use Dive that's fine but the code you want you add won't work with their templates without a lot of code rewriitng.

    This is that they did, they took the general page.php and turned it to this

    <?php

    /*
    Template Name: Custom Loan Template
    */

    get_header();

    $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );

    $show_navigation = get_post_meta( get_the_ID(), '_et_pb_project_nav', true );

    ?>

    <div id="main-content">
    <div class="container">
    <div id="content-area" class="clearfix">
    <?php
    if ( get_query_var('paged') ) $paged = get_query_var('paged');
    if ( get_query_var('page') ) $paged = get_query_var('page');

    $query = new WP_Query( array( 'post_type' => 'loan', 'paged' => $paged ) );

    if ( $query->have_posts() ) : ?>

    <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    <div class="entry">

    <h2 class="title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?></a></h2>

    <?php the_content(); ?>

    </div>

    <?php endwhile; wp_reset_postdata(); ?>
    <!-- show pagination here -->
    <?php else : ?>
    <!-- show 404 error here -->
    <?php endif; ?>
    </div>
    </div>

    </div> <!-- #main-content -->

    <?php get_footer(); ?>


    The stuff in bold is what they added. So seems to me just a bit was added?

    I now have custom posts on divi, with out a plugin, that all appear on one custom page. Cost me 20 dollars though :eek:

    When you say out of date, do you mean how they just squish everything into one column on tablets and mobile?

    Also, on mobile devices, lets say you have a three column layout with image and text below that clicks to pages or posts on your desktop layout, would you say the best approach on mobile would be to have the one area that slides side ways to keep revealing the content or just keep scrolling down the page with everything in a single column? Because the length of pages on mobile seems like it can get pretty big or would you say that doesn't really matter ?

    And do you have any examples of sites you think look great on mobile.
     
    Upvote 0

    fisicx

    Moderator
    Sep 12, 2006
    46,873
    8
    15,485
    Aldershot
    www.aerin.co.uk
    When you say out of date, do you mean how they just squish everything into one column on tablets and mobile?.
    Yes - exactly that.

    Begin with a mobile layout and work upwards. Avoid columns and sidebars where possible. You end up with a much better UX.
     
    Upvote 0
    Don't slide content sideways on mobiles (unless there is a very good and specific reason to).

    Try and collapse it down so it stacks, also look at selectively removing unneeded content from the mobile view (i'm looking at you sliders).

    As mentioned above, try and design mobile first and think about adding content and structure as you hit the different breakpoints that you have identified as being important.
     
    Upvote 0
    It depends where your target is.

    Definitely at the £400 website for a dog walking business brochure website WordPress is loosing the battle to SquareSpace right now. For two reasons
    1) The page editor is not nice ( for the end user or rapid developer ) to be able to visualise the results ( hence the growth of page builder )
    2) Self hosted wordpress is an 'expensive' activity to do securely and properly ( see the growth of WP specific hosting plans and managed WP services )

    Going forward WordPress is tackling this issues (partly at least) with the Gutenberg Project, which is advancing forward as the core page builder editor. I haven't yet played with it but there is a test version out there.

    What does this mean for the £400 dog walker business brochure website builder - well basically the barrier of entry for developers will continue to drop , and millions of more people will have this great business idea, 'if I can crack out websites to small businesses and I can sell 10 a month I can earn a decent living and call myself a 'web developer''. Not a good time to enter that market!

    However at the £50,000 website / web app end that is a different story.

    so if 99% of all business in the UK are micro businesses, or 95% i can't remember the figure, page builders are for them?

    I bought divi maybe 6 months ago and chucked something up pretty quick so i could get some traffic from search engines with a plan to manipulate it and make it better when i get time, i've since been coming into issues along the way, stuff that makes you realise even though its a page builder the average user who isn't a website developer will need help with, but, it was relatively painless to get something up and running thanks to all of the content you can find freely online. Sites like www.quiroz.co .

    If divi is no good or lacking , which it is to people who are website minded in some areas and even to me its lacking and doesn't do some things i think you'd expect it to do, what is it people need? I can't see the down side of chucking up a website that looks ok on the cheap and getting traffic from search engines and generating enquiries. What is it that people need if this is so bad as some people make out?

    Is it some sort of industry bias or hate to this sort of stuff that sculpts the arguments?
     
    Upvote 0
    Don't slide content sideways on mobiles (unless there is a very good and specific reason to).

    Try and collapse it down so it stacks, also look at selectively removing unneeded content from the mobile view (i'm looking at you sliders).

    As mentioned above, try and design mobile first and think about adding content and structure as you hit the different breakpoints that you have identified as being important.

    The trouble seems to be google will be making mobile search results reflect on what can be found on the mobile page, this is going to lead to a lot more content on mobile devices and more serious thought about how best to implement things.

    It's difficult for me and annoying to think people prefer to look on tiny screens.
     
    Upvote 0
    The trouble seems to be google will be making mobile search results reflect on what can be found on the mobile page, this is going to lead to a lot more content on mobile devices and more serious thought about how best to implement things.

    Years ago the term progressive enhancement was all the rage, and it holds true today. mobile bandwidth is much slower than desktop and screen real estate much more valuable that mobile views need to be planned for as a separate entity.

    large image sliders and modal popup boxes often don't translate well on mobile, and many css transitions, or html5 canvas effects that look great on cpu / gpu powered browsers look slow, choppy or simply crash mobile browsers.

    Try testing your pages with bandwidth throttling, and record the network logs (you can do this in chrome dev tools), as it helps give you an idea of how things will load on mobile devices.
     
    • Like
    Reactions: MASSEY and fisicx
    Upvote 0

    fisicx

    Moderator
    Sep 12, 2006
    46,873
    8
    15,485
    Aldershot
    www.aerin.co.uk
    And which is why Divi is such a poor choice of themes.

    It uses all the features that work on a desktop but not on tablets and phones. An in doing so add a whole bunch of scripts and styles that only serve to clog up the site and lower your Google score.
    It's difficult for me and annoying to think people prefer to look on tiny screens.
    That may be so but it's how people now consume content. It doesn't matter what you think or like - it only matters on what your visitors want and like.
     
    • Like
    Reactions: MASSEY
    Upvote 0

    UKSBD

    Moderator
  • Dec 30, 2005
    13,042
    1
    2,840
    this is going to lead to a lot more content on mobile devices and more serious thought about how best to implement things.

    Google have said that hiding content on mobile is ok provided it is on desktop version and isn't hidden for deceptive reasons.

    Why bother though, how often do you scroll all the way to bottom of a page on mobile? put your sales stuff at top and info at bottom (much the same as you would do on desktop anyway.
     
    • Like
    Reactions: fisicx
    Upvote 0

    Alan

    Free Member
  • Aug 16, 2011
    7,089
    1,974
    I can't see the down side of chucking up a website that looks ok on the cheap and getting traffic from search engines and generating enquiries. What is it that people need if this is so bad as some people make out?

    Is it some sort of industry bias or hate to this sort of stuff that sculpts the arguments?

    I think we agree, maybe my post wasn't that clear though.

    For simple brochure sites with minimal investment or concerns to bang them up, use a page builder, or SquareSpace.
     
    Upvote 0

    fisicx

    Moderator
    Sep 12, 2006
    46,873
    8
    15,485
    Aldershot
    www.aerin.co.uk
    Or don't use a page builder. You don't need one. People don't care about the details of the layout, it's the content that matters.

    If you change your focus from layout to content you will discover both ranking and conversion increase.
     
    Upvote 0

    fisicx

    Moderator
    Sep 12, 2006
    46,873
    8
    15,485
    Aldershot
    www.aerin.co.uk
    Very true. They seem to think a hero images and sliders, fancy fonts, animations, lots of icons, social media links and feeds and all the other bling you can paste onto a site will make it successful. It doesn't. Look at Amazon or eBay. Neither will win a design award but both are hugely successful. Not because of how they look but because of the products and service they offer.
     
    Upvote 0

    Latest Articles