I want to display my articles info in different ways, with on/off functionality, something like this:
1.title
2.text
3.date
or
1.title
2.readmore button
3.text
etc…
The script below can do this, but it’s kinda long and complicated are there are other ways to do that ? Without using array.
$firstpositioninfo is info field to display. 1 – title, 2 text etc..
<div id="pos1">
<?php
if ( $firstpositioninfo = 1 ) {
echo 'Here will be title';
elseif ( $firstpositioninfo = 2 ) {
echo 'Here will be text';
elseif ( $firstpositioninfo = 3 ) {
echo 'Here will be readmore';
.....
else { }
?></div>
<div id="pos2">
<?php
if ( $firstpositioninfo = 1 ) {
echo 'Here will be title';
elseif ( $firstpositioninfo = 2 ) {
echo 'Here will be text';
elseif ( $firstpositioninfo = 3 ) {
echo 'Here will be readmore';
.....
else { }
?></div>
Yea, a lot of better solutions exist…
Try:
Displaying each post should be also declared as function, check DRY principle.