Ah, that’s clever. You’re almost there:
function mywpp( $atts = NULL ) {
extract( shortcode_atts( array(
'id' => NULL,
'range' => 'all'
), $atts ) );
$pID = NULL;
if ( $id )
$pID = $id;
else
$pID = get_the_ID();
return '<div class="wppcounter">' . wpp_get_views($pID, $range) . '</div>';
}
add_shortcode('mwpp', 'mywpp');
I haven’t tested this, but it should work.
Let me know how it goes, alright?
Thread Starter
Vahid
(@vdamanafshan)
Héctor, where were you? I missed you:-)
Thanks so much for your answer, but I have one problem with it:
When I put something like “This post has been viewd [mwpp id=”71″ range=”X”] times.” in post/page editor, I get the following output:
This post has been viewed
X
times.
In other words, the counter is displayed in a new line. To fix this, I put
display:inline!important;
in the wppcounter class, but it didn’t work. could you please help me solve this problem?
By the way, the default value that you have specified for the range, is all
, right?
Been too busy with work projects. At my job, we were short of personnel for a bit too much time and many projects got delayed – hence the load of work got too big and you know how that ends. I still have a lot to do (and will get even more work in the upcoming days) but decided to take this weekend to work a little bit on the plugin.
Anyways, do you really need to use a DIV
element in there? How about this:
function mywpp( $atts = NULL ) {
extract( shortcode_atts( array(
'id' => NULL,
'range' => 'all'
), $atts ) );
$pID = NULL;
if ( $id )
$pID = $id;
else
$pID = get_the_ID();
return '<span class="wppcounter">' . wpp_get_views($pID, $range) . '</span>';
}
add_shortcode('mwpp', 'mywpp');
By the way, the default value that you have specified for the range, is all
, right?
Yes, that’s correct. Also the post ID will default to the current post/page ID as well if you don’t pass it to the shortcode, so you could just use [mwpp]
.
Thread Starter
Vahid
(@vdamanafshan)
Thanks again for your reply. Everything is ok now so I’m marking the topic as resolved.
By the way, I wish you success in your job and of course, your life.