Skip to main content
Improve code formatting / indentation, improve grammar
Source Link
Gabriel
  • 2.2k
  • 10
  • 22
  • 24

You are trying to get array values, so you are getting errors try. Try with wpquery likeWP_Query, like:

<?php
global $post;

$projects = array(
            
$projects = array(
    'post_type'  'post_type' => 'projects',
                'orderby'    'orderby' => 'date',
              'order'      'order' => 'DESC',
                    'post_status' => 'publish'
                );
                $projects1= new WP_Query( $projects );       
    ?>
    
    <?php if ( $projects1->have_posts() ) : 
    while ( $projects1->have_posts() ) : 
        $projects1->the_post();
        echo $post->post_name;
endwhile; endif;   endwhile; 
endif; ?>

You are trying to get array values so you are getting errors try with wpquery like

<?php
global $post;

$projects = array(
                    'post_type' => 'projects',
                    'orderby' => 'date',
                    'order' => 'DESC',
                    'post_status' => 'publish'
                );
                $projects1= new WP_Query( $projects);       
    ?>
    
    <?php if ( $projects1->have_posts() ) : while ( $projects1->have_posts() ) : $projects1->the_post();
echo $post->post_name;
endwhile; endif; 
 ?>

You are trying to get array values, so you are getting errors. Try with WP_Query, like:

global $post;        
$projects = array(
    'post_type'   => 'projects',
    'orderby'     => 'date',
    'order'       => 'DESC',
    'post_status' => 'publish'
);
$projects1= new WP_Query( $projects );          
if ( $projects1->have_posts() ) : 
    while ( $projects1->have_posts() ) : 
        $projects1->the_post();
        echo $post->post_name;
    endwhile; 
endif; 
Source Link

You are trying to get array values so you are getting errors try with wpquery like

<?php
global $post;

$projects = array(
                    'post_type' => 'projects',
                    'orderby' => 'date',
                    'order' => 'DESC',
                    'post_status' => 'publish'
                );
                $projects1= new WP_Query( $projects);       
    ?>
    
    <?php if ( $projects1->have_posts() ) : while ( $projects1->have_posts() ) : $projects1->the_post();
echo $post->post_name;
endwhile; endif; 
 ?>