如何在页面顶部创建最旧/最新的帖子按钮?

时间:2016-08-12 16:35:40

标签: php wordpress drop-down-menu

我希望在我的一个Wordpress页面上找到“按以下方式排序:最新|最旧”链接/按钮。

我发现这个问题发布在Wordpress论坛中,但它对我不起作用: https://wordpress.org/support/topic/sort-by-drop-down-with-custom-field-value?replies=29

我使用整个代码收到错误消息。当我取出最后一个块时,它在页面上正确显示,但是当我选择“最旧”时,页面刷新并且不会将最旧的排序到最新。这是我拿出的部分,因为我收到了一条错误消息(我猜这是实际工作的一部分):

describe("Service: My Service Provider", function () {
    var myService,
        DEFAULT_SETTING = 100,
        NEW_DEFAULT_SETTING = 500;

    beforeEach(function () {

        function configurationFn(myServiceProvider) {
            /* In this case, `myServiceProvider.defaultSetting` is an ES5 
             * property with only a getter. I have functions to explicitly 
             * set the property values.
             */
            expect(myServiceProvider.defaultSetting).to.equal(DEFAULT_SETTING);

            myServiceProvider.setDefaultSetting(NEW_DEFAULT_SETTING);

            expect(myServiceProvider.defaultSetting).to.equal(NEW_DEFAULT_SETTING);
        }

        module("app", [
            "app.MyServiceProvider",
            configurationFn
        ]);

        function injectionFn(_myService) {
            myService = _myService;
        }

        inject(["app.MyService", injectionFn]);
    });

    describe("#getMyDefaultSetting", function () {

        it("should test the new setting", function () {
            var result = myService.getMyDefaultSetting();

             expect(result).to.equal(NEW_DEFAULT_SETTING);
        });

    });

});

这是模板中的所有代码(它包含来自链接*的新代码,但由于最后一个块的内容而无法工作):

http://sandbox.onlinephpfunctions.com/code/49bdade9654f772df7aaa56a4da13223d0d70a93

如何格式化此代码才能使其正常工作?

0 个答案:

没有答案